group_vars/ should live inside production/. I don't know any simple way to share those vars (you can always symlink some of them)
Niko Felger <[email protected]> napisał: >Hi, > >Is it possible to use a group_vars/ directory alongside inventory >*directories* (as opposed to files)? > >Take this simplified example, which has an inventory file (staging) and >an >inventory directory (production): > >$ tree >. >└── inventories > ├── group_vars > │ └── all.yml > ├── production > │ └── hosts > └── staging > >staging and production/hosts both contain a single host: > >[localhost] >127.0.0.1 > >group_vars/all.yml defines a variable example_var: > >--- >example_var: present > >Running the staging inventory *file* picks up group_vars: > >$ ansible -i inventories/staging all -m debug -a 'msg="{{hostvars}}"' >127.0.0.1 | success >> { >"msg": "{'inventory_hostname': '127.0.0.1', *'example_var': 'present'*, > >'inventory_hostname_short': '127', 'group_names': ['localhost']}" >} > >But running the production inventory *directory* doesn't pick them up >(no >example_var in the output): > >$ ansible -i inventories/production/ all -m debug -a >'msg="{{hostvars}}"' >127.0.0.1 | success >> { >"msg": "{'inventory_hostname': '127.0.0.1', 'inventory_hostname_short': > >'127', 'group_names': ['localhost']}" >} > >How can I have the group_vars be picked up without having to duplicate >them >under inventories/production/group_vars? > >I want to use an inventory directory to mix static and dynamic >inventory, >with one inventory directory per environment (dev/stage/prod), and some > >shared vars. Maybe there's a better way to do this though? > >Thanks! >Niko > > >PS: I asked a similar (and quite long-winded) question yesterday. Since >I >didn't get an answer, I thought I'd come up with a more specific >formulation, I hope that's fine! I'm new to this list -- if there's >anything I can do to make answering my questions easier, please let me >know! > >-- >Our mailing address is: WhiteMatter Labs GmbH | Reichenberger Str. 124, > > 10999 Berlin >Handelsregister: Amtsgericht Charlottenburg, HRB 162605 B | >Geschäftsführer: >Fabian Stelzer > >-- >You received this message because you are subscribed to the Google >Groups "Ansible Project" group. >To unsubscribe from this group and stop receiving emails from it, send >an email to [email protected]. >To post to this group, send email to [email protected]. >To view this discussion on the web visit >https://groups.google.com/d/msgid/ansible-project/7905f43f-d1ab-42ae-81c0-098b180ced9b%40googlegroups.com. >For more options, visit https://groups.google.com/d/optout. -- Wysłane za pomocą K-9 Mail. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/855cb9b2-2e0a-4c59-af8d-bee998782411%40email.android.com. For more options, visit https://groups.google.com/d/optout.
