<liclass="toctree-l2"><aclass="reference internal"href="patterns.html#groups-of-groups-and-group-variables">Groups of Groups, and Group Variables</a></li>
<liclass="toctree-l2"><aclass="reference internal"href="patterns.html#groups-of-groups-and-group-variables">Groups of Groups, and Group Variables</a></li>
<liclass="toctree-l2"><aclass="reference internal"href="patterns.html#splitting-out-host-and-group-specific-data">Splitting Out Host and Group Specific Data</a></li>
<h2>YAML Inventory Format<aclass="headerlink"href="#yaml-inventory-format"title="Permalink to this headline">¶</a></h2>
<h2>Splitting Out Host and Group Specific Data<aclass="headerlink"href="#splitting-out-host-and-group-specific-data"title="Permalink to this headline">¶</a></h2>
<p>For that prefer to use it, the inventory file can also be expressed in
<p>In Ansible 0.6 and later, in addition to the storing variables directly in the INI file, host and
YAML:</p>
group variables can be stored in individual files relative to the inventory file. These
<p>For instance, suppose you have hosts grouped by datacenter, and each datacenter
uses some different servers. The data in the groupfile ‘/etc/ansible/group_vars/raleigh’ for
the ‘raleigh’ group might look like:</p>
<divclass="highlight-python"><pre>---
<divclass="highlight-python"><pre>---
ntp_server: acme.example.org
# some ungrouped hosts, either use the short string form or the "host: " prefix
database_server: storage.example.org</pre>
- host: jupiter
- mars
# variables can be assigned like this...
- host: saturn
vars:
- moon: titan
# groups can also set variables to all hosts in the group
# here are a bunch of hosts using a non-standard SSH port
# and also defining a variable 'ntpserver'
- group: greek
hosts:
- zeus
- hera
- poseidon
vars:
- ansible_ssh_port: 3000
- ntp_server: olympus.example.com
# individual hosts can still set variables inside of groups too
# so you aren't limited to just group variables and host variables.
- group: norse
hosts:
- host: thor
vars:
- hammer: True
- odin
- loki
vars:
- asdf: 1234</pre>
</div>
</div>
<p>It is ok if these files do not exist, this is an optional feature.</p>
<p>Tip: Keeping your inventory file and variables in a git repo (or other version control)
is an excellent way to track changes to your inventory and host variables.</p>
<p>Tip: If you ever have two python interpreters on a system, set a variable called ‘ansible_python_interpreter’ to
<p>Tip: If you ever have two python interpreters on a system, set a variable called ‘ansible_python_interpreter’ to
the Python interpreter path you would like to use. (This is available in version 0.5 and later)</p>
the Python interpreter path you would like to use.</p>
<p>Tip: Be sure to start your YAML file with the YAML record designator <ttclass="docutils literal"><spanclass="pre">---</span></tt>.</p>
<p>Tip: Be sure to start any YAML file with the YAML record designator <ttclass="docutils literal"><spanclass="pre">---</span></tt> on the first line.</p>
</div>
<divclass="section"id="yaml-inventory">
<h2>YAML Inventory<aclass="headerlink"href="#yaml-inventory"title="Permalink to this headline">¶</a></h2>
<p>Ansible’s YAML inventory format is deprecated and will be removed in Ansible 0.7. Ansible 0.6 includes
a <aclass="reference external"href="https://github.com/ansible/ansible/blob/devel/examples/scripts/yaml_to_ini.py">conversion script</a>.</p>