mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 03:53:59 -07:00
Docs rebuild
This commit is contained in:
parent
7a4df9e2fc
commit
fe2d1c7cc9
8 changed files with 49 additions and 50 deletions
|
@ -98,20 +98,17 @@ described in the ‘patterns’ documentation. This is just like the fi
|
|||
<h2>Vars section<a class="headerlink" href="#vars-section" title="Permalink to this headline">¶</a></h2>
|
||||
<p>A list of variables and values that can be used in the plays. These can be used in templates
|
||||
or ‘action’ lines and are dereferenced using <tt class="docutils literal"><span class="pre">`jinja2`</span></tt> syntax like this:</p>
|
||||
<blockquote>
|
||||
<div>{{ varname }}</div></blockquote>
|
||||
<div class="highlight-python"><pre>{{ varname }}</pre>
|
||||
</div>
|
||||
<p>Further, if there are discovered variables about the system (say, if facter or ohai were
|
||||
installed) these variables bubble up back into the playbook, and can be used on each
|
||||
system just like explicitly set variables. Facter variables are prefixed with ‘<a href="#id1"><span class="problematic" id="id2">facter_</span></a>‘
|
||||
and Ohai variables are prefixed with ‘<a href="#id3"><span class="problematic" id="id4">ohai_</span></a>‘. So for instance, if I wanted to write the
|
||||
hostname into the /etc/motd file, I could say:</p>
|
||||
<blockquote>
|
||||
<div><ul class="simple">
|
||||
<li>name: write the motd</li>
|
||||
<li>action: template src=/srv/templates/motd.j2 dest=/etc/motd</li>
|
||||
</ul>
|
||||
</div></blockquote>
|
||||
<p>And in /srv/templates/motd.j2::</p>
|
||||
<div class="highlight-python"><pre>- name: write the motd
|
||||
- action: template src=/srv/templates/motd.j2 dest=/etc/motd</pre>
|
||||
</div>
|
||||
<p>And in /srv/templates/motd.j2:</p>
|
||||
<div class="highlight-python"><pre>You are logged into {{ facter_hostname }}</pre>
|
||||
</div>
|
||||
<p>But we’re getting ahead of ourselves. Let’s talk about tasks.</p>
|
||||
|
@ -134,12 +131,9 @@ command line. See the module documentation for more info.</p>
|
|||
<p>Variables, as mentioned above, can be used in action lines. So if, hypothetically, you wanted
|
||||
to make a directory on each system named after the hostname ... yeah, that’s I know silly ... you could
|
||||
do it like so:</p>
|
||||
<blockquote>
|
||||
<div><ul class="simple">
|
||||
<li>name: make a directory</li>
|
||||
<li>action: mkdir /tmp/{{ facter_hostname }}</li>
|
||||
</ul>
|
||||
</div></blockquote>
|
||||
<div class="highlight-python"><pre>- name: make a directory
|
||||
- action: mkdir /tmp/{{ facter_hostname }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="notify-statements">
|
||||
<h2>Notify statements<a class="headerlink" href="#notify-statements" title="Permalink to this headline">¶</a></h2>
|
||||
|
@ -162,25 +156,16 @@ complete in a particular play.</p>
|
|||
<h2>Includes<a class="headerlink" href="#includes" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Not all tasks have to be listed directly in the main file. An include file can contain
|
||||
a list of tasks (in YAML) as well, optionally passing extra variables into the file.
|
||||
Variables passed in can be deferenced like this (assume a variable named ‘user’)</p>
|
||||
<blockquote>
|
||||
<div>{{ user }}</div></blockquote>
|
||||
Variables passed in can be deferenced like this (assume a variable named ‘user’):</p>
|
||||
<div class="highlight-python"><pre>{{ user }}</pre>
|
||||
</div>
|
||||
<p>For instance, if deploying multiple wordpress instances, I could contain all of my tasks
|
||||
in a wordpress.yml file, and use it like so:</p>
|
||||
<blockquote>
|
||||
<div><ul>
|
||||
<li><dl class="first docutils">
|
||||
<dt>tasks:</dt>
|
||||
<dd><ul class="first last simple">
|
||||
<li>include: wordpress.yml user=timmy</li>
|
||||
<li>include: wordpress.yml user=alice</li>
|
||||
<li>include: wordpress.yml user=bob</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
</div></blockquote>
|
||||
<div class="highlight-python"><pre>- tasks:
|
||||
- include: wordpress.yml user=timmy
|
||||
- include: wordpress.yml user=alice
|
||||
- include: wordpress.yml user=bob</pre>
|
||||
</div>
|
||||
<p>In addition to the explicitly passed in parameters, all variables from the vars section
|
||||
are also available.</p>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue