mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Rebuild
This commit is contained in:
parent
0c2dd7b057
commit
1c5f5acadf
2 changed files with 11 additions and 10 deletions
|
@ -533,11 +533,7 @@ include files to do this.</p>
|
||||||
<div class="highlight-python"><pre>- tasks:
|
<div class="highlight-python"><pre>- tasks:
|
||||||
- include: tasks/foo.yml</pre>
|
- include: tasks/foo.yml</pre>
|
||||||
</div>
|
</div>
|
||||||
<p>Variables passed in can be used in the include files too. Assume a variable named ‘user’. Using
|
<p>You can also pass variables into includes directly. We might call this a ‘parameterized include’.</p>
|
||||||
<cite>jinja2</cite> syntax, anywhere in the included file, you can say:</p>
|
|
||||||
<div class="highlight-python"><pre>{{ user }}</pre>
|
|
||||||
</div>
|
|
||||||
<p>I can also pass variables into includes directly. We might call this a ‘parameterized include’.</p>
|
|
||||||
<p>For instance, if deploying multiple wordpress instances, I could
|
<p>For instance, if deploying multiple wordpress instances, I could
|
||||||
contain all of my wordpress tasks in a single wordpress.yml file, and use it like so:</p>
|
contain all of my wordpress tasks in a single wordpress.yml file, and use it like so:</p>
|
||||||
<div class="highlight-python"><pre>- tasks:
|
<div class="highlight-python"><pre>- tasks:
|
||||||
|
@ -545,15 +541,20 @@ contain all of my wordpress tasks in a single wordpress.yml file, and use it lik
|
||||||
- include: wordpress.yml user=alice
|
- include: wordpress.yml user=alice
|
||||||
- include: wordpress.yml user=bob</pre>
|
- include: wordpress.yml user=bob</pre>
|
||||||
</div>
|
</div>
|
||||||
|
<p>Variables passed in can be used in the included files. Using
|
||||||
|
<cite>jinja2</cite> syntax, in the included file, you can reference them like this:</p>
|
||||||
|
<div class="highlight-python"><pre>{{ user }}</pre>
|
||||||
|
</div>
|
||||||
|
<p>or, more simply, using Ansible’s simplified variable syntax:</p>
|
||||||
|
<div class="highlight-python"><pre>$user</pre>
|
||||||
|
</div>
|
||||||
<p>In addition to the explicitly passed in parameters, all variables from
|
<p>In addition to the explicitly passed in parameters, all variables from
|
||||||
the vars section are also available for use here as well. Variables that bubble
|
the vars section are also available for use here as well.</p>
|
||||||
up from tools like facter and ohai are not usable here though – but they ARE available for use
|
|
||||||
inside ‘action’ lines and in templates.</p>
|
|
||||||
<div class="admonition note">
|
<div class="admonition note">
|
||||||
<p class="first admonition-title">Note</p>
|
<p class="first admonition-title">Note</p>
|
||||||
<p class="last">Include statements are only usable from the top level
|
<p class="last">Include statements are only usable from the top level
|
||||||
playbook file. This means includes can not include other
|
playbook file. This means includes can not include other
|
||||||
includes.</p>
|
includes. This may be implemented in a later release.</p>
|
||||||
</div>
|
</div>
|
||||||
<p>Includes can also be used in the ‘handlers’ section, for instance, if you
|
<p>Includes can also be used in the ‘handlers’ section, for instance, if you
|
||||||
want to define how to restart apache, you only have to do that once for all
|
want to define how to restart apache, you only have to do that once for all
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue