mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Update the inventory docs + rebuild
This commit is contained in:
parent
52bcdf5e38
commit
db014182e6
16 changed files with 94 additions and 95 deletions
|
@ -275,7 +275,7 @@ languages:
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
2
api.html
2
api.html
|
@ -359,7 +359,7 @@ a conf.d file appropriately or something similar. Who knows?</p>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -297,7 +297,7 @@ This way you have an audit trail describing when and why you changed the rules a
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -382,7 +382,7 @@ a simplified syntax for this.</p>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
2
faq.html
2
faq.html
|
@ -388,7 +388,7 @@ tasks – whether for a QA sytem, build system, or anything you can think of
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -190,7 +190,7 @@ s.parentNode.insertBefore(ga, s);
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -377,7 +377,7 @@ explore, but you already have a fully working infrastructure!</p>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -301,7 +301,8 @@ Email: <input type=text name=email> <input type=submit name="sub" val
|
||||||
<li class="toctree-l2"><a class="reference internal" href="patterns.html#host-variables">Host Variables</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="patterns.html#host-variables">Host Variables</a></li>
|
||||||
<li class="toctree-l2"><a class="reference internal" href="patterns.html#group-variables">Group Variables</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="patterns.html#group-variables">Group Variables</a></li>
|
||||||
<li class="toctree-l2"><a class="reference internal" href="patterns.html#groups-of-groups-and-group-variables">Groups of Groups, and Group Variables</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="patterns.html#groups-of-groups-and-group-variables">Groups of Groups, and Group Variables</a></li>
|
||||||
<li class="toctree-l2"><a class="reference internal" href="patterns.html#yaml-inventory-format">YAML Inventory Format</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="patterns.html#splitting-out-host-and-group-specific-data">Splitting Out Host and Group Specific Data</a></li>
|
||||||
|
<li class="toctree-l2"><a class="reference internal" href="patterns.html#yaml-inventory">YAML Inventory</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="toctree-l1"><a class="reference internal" href="examples.html">Command Line</a><ul>
|
<li class="toctree-l1"><a class="reference internal" href="examples.html">Command Line</a><ul>
|
||||||
|
@ -453,7 +454,7 @@ Puppet Labs, and is now with <a class="reference external" href="http://rpath.co
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -455,7 +455,7 @@ Stop by the mailing list to inquire about requirements.</p>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -833,7 +833,7 @@ yum pkg=httpd state=installed</pre>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -153,7 +153,8 @@ s.parentNode.insertBefore(ga, s);
|
||||||
<li><a class="reference internal" href="#host-variables">Host Variables</a></li>
|
<li><a class="reference internal" href="#host-variables">Host Variables</a></li>
|
||||||
<li><a class="reference internal" href="#group-variables">Group Variables</a></li>
|
<li><a class="reference internal" href="#group-variables">Group Variables</a></li>
|
||||||
<li><a class="reference internal" href="#groups-of-groups-and-group-variables">Groups of Groups, and Group Variables</a></li>
|
<li><a class="reference internal" href="#groups-of-groups-and-group-variables">Groups of Groups, and Group Variables</a></li>
|
||||||
<li><a class="reference internal" href="#yaml-inventory-format">YAML Inventory Format</a></li>
|
<li><a class="reference internal" href="#splitting-out-host-and-group-specific-data">Splitting Out Host and Group Specific Data</a></li>
|
||||||
|
<li><a class="reference internal" href="#yaml-inventory">YAML Inventory</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -234,7 +235,7 @@ with the aforementioned bracket headers in the inventory file:</p>
|
||||||
<div class="highlight-python"><pre>webservers
|
<div class="highlight-python"><pre>webservers
|
||||||
webservers:dbservers</pre>
|
webservers:dbservers</pre>
|
||||||
</div>
|
</div>
|
||||||
<p>In 0.5 and later, you can exclude groups as well, for instance, all webservers not in Phoenix:</p>
|
<p>You can exclude groups as well, for instance, all webservers not in Phoenix:</p>
|
||||||
<div class="highlight-python"><pre>webservers:!phoenix</pre>
|
<div class="highlight-python"><pre>webservers:!phoenix</pre>
|
||||||
</div>
|
</div>
|
||||||
<p>Individual host names (or IPs), but not groups, can also be referenced using
|
<p>Individual host names (or IPs), but not groups, can also be referenced using
|
||||||
|
@ -296,49 +297,45 @@ northeast
|
||||||
southwest
|
southwest
|
||||||
southeast</pre>
|
southeast</pre>
|
||||||
</div>
|
</div>
|
||||||
|
<p>If you need to store lists or hash data, or prefer to keep host and group specific variables
|
||||||
|
seperate from the inventory file, see the next section.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="yaml-inventory-format">
|
<div class="section" id="splitting-out-host-and-group-specific-data">
|
||||||
<h2>YAML Inventory Format<a class="headerlink" href="#yaml-inventory-format" title="Permalink to this headline">¶</a></h2>
|
<h2>Splitting Out Host and Group Specific Data<a class="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
|
||||||
|
variable files are in YAML format.</p>
|
||||||
|
<p>Assuming the inventory file path is:</p>
|
||||||
|
<div class="highlight-python"><pre>/etc/ansible/hosts</pre>
|
||||||
|
</div>
|
||||||
|
<p>If the host is named ‘foosball’, and in groups ‘raleigh’ and ‘webservers’, variables
|
||||||
|
in YAML files at the following locations will be made available to the host:</p>
|
||||||
|
<div class="highlight-python"><pre>/etc/ansible/group_vars/raleigh
|
||||||
|
/etc/ansible/group_vars/webservers
|
||||||
|
/etc/ansible/host_vars/foosball</pre>
|
||||||
|
</div>
|
||||||
|
<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>
|
||||||
<div class="highlight-python"><pre>---
|
<div class="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 <tt class="docutils literal"><span class="pre">---</span></tt>.</p>
|
<p>Tip: Be sure to start any YAML file with the YAML record designator <tt class="docutils literal"><span class="pre">---</span></tt> on the first line.</p>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="yaml-inventory">
|
||||||
|
<h2>YAML Inventory<a class="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 <a class="reference external" href="https://github.com/ansible/ansible/blob/devel/examples/scripts/yaml_to_ini.py">conversion script</a>.</p>
|
||||||
|
<p>Usage:</p>
|
||||||
|
<div class="highlight-python"><div class="highlight"><pre><span class="n">yaml_to_ini</span><span class="o">.</span><span class="n">py</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ansible</span><span class="o">/</span><span class="n">hosts</span>
|
||||||
|
</pre></div>
|
||||||
|
</div>
|
||||||
<div class="admonition-see-also admonition seealso">
|
<div class="admonition-see-also admonition seealso">
|
||||||
<p class="first admonition-title">See also</p>
|
<p class="first admonition-title">See also</p>
|
||||||
<dl class="last docutils">
|
<dl class="last docutils">
|
||||||
|
@ -370,7 +367,7 @@ the Python interpreter path you would like to use. (This is available in versio
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -483,7 +483,7 @@ package is installed. Try it!</p>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -508,7 +508,7 @@ logs from ansible-pull runs would be an excellent way to gather and analyze remo
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -67,7 +67,7 @@ with the aforementioned bracket headers in the inventory file::
|
||||||
webservers
|
webservers
|
||||||
webservers:dbservers
|
webservers:dbservers
|
||||||
|
|
||||||
In 0.5 and later, you can exclude groups as well, for instance, all webservers not in Phoenix::
|
You can exclude groups as well, for instance, all webservers not in Phoenix::
|
||||||
|
|
||||||
webservers:!phoenix
|
webservers:!phoenix
|
||||||
|
|
||||||
|
@ -138,51 +138,52 @@ variables to groups. These variables can be used by /usr/bin/ansible-playbook,
|
||||||
southwest
|
southwest
|
||||||
southeast
|
southeast
|
||||||
|
|
||||||
YAML Inventory Format
|
If you need to store lists or hash data, or prefer to keep host and group specific variables
|
||||||
+++++++++++++++++++++
|
seperate from the inventory file, see the next section.
|
||||||
|
|
||||||
For that prefer to use it, the inventory file can also be expressed in
|
Splitting Out Host and Group Specific Data
|
||||||
YAML::
|
++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
In Ansible 0.6 and later, in addition to the storing variables directly in the INI file, host and
|
||||||
|
group variables can be stored in individual files relative to the inventory file. These
|
||||||
|
variable files are in YAML format.
|
||||||
|
|
||||||
|
Assuming the inventory file path is::
|
||||||
|
|
||||||
|
/etc/ansible/hosts
|
||||||
|
|
||||||
|
If the host is named 'foosball', and in groups 'raleigh' and 'webservers', variables
|
||||||
|
in YAML files at the following locations will be made available to the host::
|
||||||
|
|
||||||
|
/etc/ansible/group_vars/raleigh
|
||||||
|
/etc/ansible/group_vars/webservers
|
||||||
|
/etc/ansible/host_vars/foosball
|
||||||
|
|
||||||
|
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::
|
||||||
|
|
||||||
---
|
---
|
||||||
|
ntp_server: acme.example.org
|
||||||
|
database_server: storage.example.org
|
||||||
|
|
||||||
# some ungrouped hosts, either use the short string form or the "host: " prefix
|
It is ok if these files do not exist, this is an optional feature.
|
||||||
- host: jupiter
|
|
||||||
- mars
|
|
||||||
|
|
||||||
# variables can be assigned like this...
|
Tip: Keeping your inventory file and variables in a git repo (or other version control)
|
||||||
- host: saturn
|
is an excellent way to track changes to your inventory and host variables.
|
||||||
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
|
|
||||||
|
|
||||||
Tip: If you ever have two python interpreters on a system, set a variable called 'ansible_python_interpreter' to
|
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)
|
the Python interpreter path you would like to use.
|
||||||
|
|
||||||
Tip: Be sure to start your YAML file with the YAML record designator ``---``.
|
YAML Inventory
|
||||||
|
++++++++++++++
|
||||||
|
|
||||||
|
Ansible's YAML inventory format is deprecated and will be removed in Ansible 0.7. Ansible 0.6 includes
|
||||||
|
a `conversion script <https://github.com/ansible/ansible/blob/devel/examples/scripts/yaml_to_ini.py>`_.
|
||||||
|
|
||||||
|
Usage::
|
||||||
|
|
||||||
|
yaml_to_ini.py /etc/ansible/hosts
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ s.parentNode.insertBefore(ga, s);
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
© Copyright 2012 Michael DeHaan.<br/>
|
© Copyright 2012 Michael DeHaan.<br/>
|
||||||
Last updated on Jul 04, 2012.<br/>
|
Last updated on Jul 20, 2012.<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue