page 20 from course 9.0 see:
"To define group variables for the servers group, you would create a YAML file named group_vars/servers.yml, and then the contents of that file would set variables to values"
but in the same page in examples you shows files without yaml.
"
If you need to define difference values for each data center, set a group variable for each data center host group:
[admin@station project]$ cat ~/project/group_vars/datacenter1 package: httpd [admin@station project]$ cat ~/project/group_vars/datacenter2 package: apache
Finally what is correct?
So the book might be a bit unclear, but it does show the YAML ...
group_vars/servers.yml
user: joe
Technically, that is a valid YAML. It doesn't have the usual "---" at the top and almost nobody uses the "..." at the bottom anymore.
I'm guessing you would have rather seen the example shown like this ...
[admin@station project]$ cat group_vars/servers.yml user: joe
To show that is what was in the file and you would like to have seen ...
project ├── ansible.cfg ├── group_vars │ ├── datacenters │ ├── datacenters1 │ └── datacenters2 │ ├── servers ├── host_vars │ ├── demo1.example.com │ ├── demo2.example.com │ ├── demo3.example.com │ └── demo4.example.com ├── inventory └── playbook.yml
To be a more complete and runnnig example?
The thing to keep in mind is that all the variables get added together and if a variable is defined with different values in different places, generally speaking the more "specific" or "narrowly-scoped" wins. It is extremely important to understand how to work with variables and understand the variable precedence.
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.