0

Consider the directory structure:

 - files
 - galaxy_roles
 - roles
 - projects
    - project_a
      - group_vars
      - roles
      - hosts
      - ansible.cfg
      - play.yml

With the ansible.cfg set to look for roles in the current roles directory, the outermost roles directory and the galaxy_roles directory, how can tasks and configurations which use lookup find files in the outermost files directory?

Files residing here could be shared between all roles - e.g. public keys.

Ansible only wants to look in the files directory in the various role folders.

jamieburchell
  • 761
  • 1
  • 5
  • 18
  • 1
    Only the `file` dir adjacent to playbook will be parsed additionally. This is a very strange ansible project layout. I Suggest you have a look at [the recommend layouts in the best practice documentation](https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#directory-layout). Regarding roles versioning, downloading and dependency management, you can have a look at [this answer](https://stackoverflow.com/questions/55773505/where-to-place-requirements-yml-for-ansible-and-use-it-to-resolve-dependencies) for some hints. – Zeitounator Jan 23 '20 at 22:46
  • I have done several times. The suggested layouts don't really fit with my use case for Ansible. It seems strange to me that we can't control where lookup searches for files. Regardless of layout, not being able to share files globally between different projects and environments seems like an oversight. – jamieburchell Jan 23 '20 at 23:24
  • Why don't you simply put you "global" files in a global role you can put in any project ? – Zeitounator Jan 23 '20 at 23:38
  • That is a great suggestion, but I don't think it will work. An Ansible Galaxy role is responsible for creating users on my servers. This role would be used in all projects most likely. It has configuration for each user's public key, so in the config for this role the lookup tries to point to a central location for the public keys, and can't find them. – jamieburchell Jan 24 '20 at 00:02

0 Answers0