Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support for relative copying from inventories folder #37426

Closed
mat013 opened this issue Mar 14, 2018 · 5 comments
Closed

Feature request: support for relative copying from inventories folder #37426

mat013 opened this issue Mar 14, 2018 · 5 comments
Labels
affects_2.6 This issue/PR affects Ansible v2.6 feature This issue/PR relates to a feature request. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@mat013
Copy link

mat013 commented Mar 14, 2018

Feature Idea

COMPONENT NAME

Ansible

SUMMARY

In the best practice section of the ansible documentation
http://docs.ansible.com/ansible/latest/playbooks_best_practices.html#alternative-directory-layout

it is suggested that the organisation of files are split by each inventory that one makes in this case per environment. It gives the advantage that anything, which is relevant for that particular environment are organised together. Currently only values are supported. I would like to propose an extension/enhancement to this idea, which is to be able to place files which are only relevant to a particular environment. e.g. SSL certificates.

And then it should be possible for the copy task to locate to the files by referring relative.

In the following example when using the copy task and referring relative to the webserver role, then searching for the file will only be carried out in the roles/webserver/files tasks. My proposal is that assuming the inventory is the inventories/production/hosts then when referring relative in a copy task for the webserver role should look in inventories/production/roles/webserver/files as well, and it should have higher precedence than roles/webserver/files

+-- inventories
  +-- production
       +-- hosts
       +-- roles
            +-- webserver
                  +-- files
                       + certificate.pem
   +-- development
       +-- hosts
       +-- roles
            +-- webserver
                  +-- files
                       + certificate.pem
+-- roles
     +-- webserver
          +-- tasks
               + ...

The motivation behind this proposal is:

  • it seems to be more consistent with the philosophy of this how to organise the files in alternative directory layout
  • it would provide a cleaner organisation when one has decided to use this philosophy rather than have to place environment specific files into roles/webserver/files/production/certificate.pem and use some logic to resolve it to a particular environment
  • It would also be possible to restrict some of the inventories in case that only some part of an organisation should be allowed. e.g. production should only be allowed by operations team.
@ansibot
Copy link
Contributor

ansibot commented Mar 14, 2018

@mat013 Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information.

Here are the items we could not find in your description:

  • component name

Please set the description of this issue with this template:
https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE.md

click here for bot help

@ansibot ansibot added affects_2.6 This issue/PR affects Ansible v2.6 feature This issue/PR relates to a feature request. needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed needs_info This issue requires further information. Please answer any outstanding questions. needs_template This issue/PR has an incomplete description. Please fill in the proposed template correctly. labels Mar 14, 2018
@jborean93
Copy link
Contributor

@mat013 you are probably going to be better off adding this proposal to the next Ansible meeting and talking about it there ansible/community#296.

@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Mar 15, 2018
@mat013
Copy link
Author

mat013 commented Mar 16, 2018

Thanks. I will look at it when I am back from vacation.

@bcoca
Copy link
Member

bcoca commented Apr 17, 2018

We voted in irc meeting and decided to decline the proposal

@bcoca bcoca closed this as completed Apr 17, 2018
@mat013
Copy link
Author

mat013 commented Apr 17, 2018

I found a workaround for the issue which is to add a variable in the group_vars/all file

e.g.:

files_resources: "{{ inventory_dir + '/roles/' + role_name + 'files' }}"

And then prefix where ever the filepath is needed

e.g.

{{ lookup_file('file', files_resource + '/...

@ansible ansible locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.6 This issue/PR affects Ansible v2.6 feature This issue/PR relates to a feature request. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

4 participants