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:
|
||||
- include: tasks/foo.yml</pre>
|
||||
</div>
|
||||
<p>Variables passed in can be used in the include files too. Assume a variable named ‘user’. Using
|
||||
<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>You 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
|
||||
contain all of my wordpress tasks in a single wordpress.yml file, and use it like so:</p>
|
||||
<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=bob</pre>
|
||||
</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
|
||||
the vars section are also available for use here as well. Variables that bubble
|
||||
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>
|
||||
the vars section are also available for use here as well.</p>
|
||||
<div class="admonition note">
|
||||
<p class="first admonition-title">Note</p>
|
||||
<p class="last">Include statements are only usable from the top level
|
||||
playbook file. This means includes can not include other
|
||||
includes.</p>
|
||||
includes. This may be implemented in a later release.</p>
|
||||
</div>
|
||||
<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
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue