Hi Daniel, Yes, I think I understand the difference between a role and a playbook - but it's all still a bit hazy - I have been probably doing super bad practice (incorporating variables into an inventory file) recently, so I really trying to do it properly!
Thanks a million for the list - really helpful! Cheers nik On Saturday, 29 July 2017 19:06:58 UTC+1, Daniel JD wrote: > > Hey Nicholas, > > there are many possible locations where you could define it. Are you aware > that there is a difference between "roles" and "playbooks"? The filelayout > you created is a role- layout. A role contains a set of tasks which are > applied to a host. The decision which host the role is running on is > already made. So every variable you define in inside the role is available > to that host. > > So, you could define the variable inside the defaults/main.yml (least > precedence), in the vars/main.yml or directly in the task. > > Here is a complete list: > > > - role defaults [1] > <http://docs.ansible.com/ansible/latest/playbooks_variables.html#id10> > - inventory INI or script group vars [2] > <http://docs.ansible.com/ansible/latest/playbooks_variables.html#id11> > - inventory group_vars/all > - playbook group_vars/all > - inventory group_vars/* > - playbook group_vars/* > - inventory INI or script host vars [2] > <http://docs.ansible.com/ansible/latest/playbooks_variables.html#id11> > - inventory host_vars/* > - playbook host_vars/* > - host facts > - play vars > - play vars_prompt > - play vars_files > - role vars (defined in role/vars/main.yml) > - block vars (only for tasks in block) > - task vars (only for the task) > - role (and include_role) params > - include params > - include_vars > - set_facts / registered vars > - extra vars (always win precedence) > > > Check out this doc: > http://docs.ansible.com/ansible/latest/playbooks_variables.html > > > > Am Freitag, 28. Juli 2017 20:41:37 UTC+2 schrieb Nicholas Sheridan: >> >> Hi Forum, >> >> >> If I write playbooks using the "ansible-galaxy init" command: >> >> ansible-galaxy init standardisationBot >> >> Which gives me this >> >> shr1mac1:standardisationBot nsheridan$ tree >> >> . >> >> ├── README.md >> >> ├── defaults >> >> │ └── main.yml >> >> ├── handlers >> >> │ └── main.yml >> >> ├── meta >> >> │ └── main.yml >> >> ├── tasks >> >> │ └── main.yml >> >> ├── tests >> >> │ ├── inventory >> >> │ └── test.yml >> >> └── vars >> >> └── main.yml >> >> >> 6 directories, 8 files >> >> shr1mac1:standardisationBot nsheridan$ >> >> How do I associate a variable with host R1? more's the point where do I >> put anything???? Can anyone help? >> >> Thanks nik >> > -- 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/6b2a5d44-bf07-4ca1-99e6-34045891f096%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
