mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Added info about ignore_errors: True and added a user to the who uses page
This commit is contained in:
@@ -150,7 +150,8 @@ s.parentNode.insertBefore(ga, s);
|
||||
<span class="localtoc"><ul>
|
||||
<li><a class="reference internal" href="#">Advanced Playbooks</a><ul>
|
||||
<li><a class="reference internal" href="#tags">Tags</a></li>
|
||||
<li><a class="reference internal" href="#playbooks-including-playbooks">Playbooks Including Playbooks</a><ul>
|
||||
<li><a class="reference internal" href="#playbooks-including-playbooks">Playbooks Including Playbooks</a></li>
|
||||
<li><a class="reference internal" href="#ignoring-failed-commands">Ignoring Failed Commands</a></li>
|
||||
<li><a class="reference internal" href="#accessing-complex-variable-data">Accessing Complex Variable Data</a></li>
|
||||
<li><a class="reference internal" href="#accessing-information-about-other-hosts">Accessing Information About Other Hosts</a></li>
|
||||
<li><a class="reference internal" href="#variable-file-seperation">Variable File Seperation</a></li>
|
||||
@@ -168,8 +169,6 @@ s.parentNode.insertBefore(ga, s);
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</span>
|
||||
</li>
|
||||
|
||||
@@ -234,8 +233,18 @@ reconfigure all of your systems like this:</p>
|
||||
</div>
|
||||
<p>This concept works great with tags to rapidly select exactly what plays you want to run, and exactly
|
||||
what parts of those plays.</p>
|
||||
</div>
|
||||
<div class="section" id="ignoring-failed-commands">
|
||||
<h2>Ignoring Failed Commands<a class="headerlink" href="#ignoring-failed-commands" title="Permalink to this headline">¶</a></h2>
|
||||
<p>(New in 0.6) Generally playbooks will stop executing any more steps on a host that has a failure.
|
||||
Sometimes, though, you want to continue on. To do so, write a task that looks like this:</p>
|
||||
<div class="highlight-python"><pre>- name: this will not be counted as a failure
|
||||
action: command /bin/false
|
||||
ignore_errors: True</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="accessing-complex-variable-data">
|
||||
<h3>Accessing Complex Variable Data<a class="headerlink" href="#accessing-complex-variable-data" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Accessing Complex Variable Data<a class="headerlink" href="#accessing-complex-variable-data" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Some provided facts, like networking information, are made available as nested data structures. To access
|
||||
them a simple ‘$foo’ is not sufficient, but it is still easy to do. Here’s how we get an IP address:</p>
|
||||
<div class="highlight-python"><pre>${ansible_eth0.ipv4.address}</pre>
|
||||
@@ -250,7 +259,7 @@ that is preferred:</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="accessing-information-about-other-hosts">
|
||||
<h3>Accessing Information About Other Hosts<a class="headerlink" href="#accessing-information-about-other-hosts" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Accessing Information About Other Hosts<a class="headerlink" href="#accessing-information-about-other-hosts" title="Permalink to this headline">¶</a></h2>
|
||||
<p>If your database server wants to check the value of a ‘fact’ from another node, or an inventory variable
|
||||
assigned to another node, it’s easy to do so within a template or even an action line:</p>
|
||||
<div class="highlight-python"><pre>${hostvars.hostname.factname}</pre>
|
||||
@@ -276,7 +285,7 @@ period.</p>
|
||||
<p>Don’t worry about any of this unless you think you need it. You’ll know when you do.</p>
|
||||
</div>
|
||||
<div class="section" id="variable-file-seperation">
|
||||
<h3>Variable File Seperation<a class="headerlink" href="#variable-file-seperation" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Variable File Seperation<a class="headerlink" href="#variable-file-seperation" title="Permalink to this headline">¶</a></h2>
|
||||
<p>It’s a great idea to keep your playbooks under source control, but
|
||||
you may wish to make the playbook source public while keeping certain
|
||||
important variables private. Similarly, sometimes you may just
|
||||
@@ -305,7 +314,7 @@ password: magic</pre>
|
||||
<p>NOTE: It’s also possible to keep per-host and per-group variables in very similar files, this is covered in <a class="reference internal" href="patterns.html#patterns"><em>Inventory & Patterns</em></a>.</p>
|
||||
</div>
|
||||
<div class="section" id="prompting-for-sensitive-data">
|
||||
<h3>Prompting For Sensitive Data<a class="headerlink" href="#prompting-for-sensitive-data" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Prompting For Sensitive Data<a class="headerlink" href="#prompting-for-sensitive-data" title="Permalink to this headline">¶</a></h2>
|
||||
<p>You may wish to prompt the user for certain input, and can
|
||||
do so with the similarly named ‘vars_prompt’ section. This has uses
|
||||
beyond security, for instance, you may use the same playbook for all
|
||||
@@ -334,7 +343,7 @@ some other options, but otherwise works equivalently:</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="passing-variables-on-the-command-line">
|
||||
<h3>Passing Variables On The Command Line<a class="headerlink" href="#passing-variables-on-the-command-line" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Passing Variables On The Command Line<a class="headerlink" href="#passing-variables-on-the-command-line" title="Permalink to this headline">¶</a></h2>
|
||||
<p>In addition to <cite>vars_prompt</cite> and <cite>vars_files</cite>, it is possible to send variables over
|
||||
the ansible command line. This is particularly useful when writing a generic release playbook
|
||||
where you may want to pass in the version of the application to deploy:</p>
|
||||
@@ -352,7 +361,7 @@ ansible-playbook release.yml --extra-vars "hosts=vipers user=starbuck"</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="conditional-execution">
|
||||
<h3>Conditional Execution<a class="headerlink" href="#conditional-execution" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Conditional Execution<a class="headerlink" href="#conditional-execution" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Sometimes you will want to skip a particular step on a particular host. This could be something
|
||||
as simple as not installing a certain package if the operating system is a particular version,
|
||||
or it could be something like performing some cleanup steps if a filesystem is getting full.</p>
|
||||
@@ -387,7 +396,7 @@ there will be accessible to future tasks:</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="conditional-imports">
|
||||
<h3>Conditional Imports<a class="headerlink" href="#conditional-imports" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Conditional Imports<a class="headerlink" href="#conditional-imports" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Sometimes you will want to do certain things differently in a playbook based on certain criteria.
|
||||
Having one playbook that works on multiple platforms and OS versions is a good example.</p>
|
||||
<p>As an example, the name of the Apache package may be different between CentOS and Debian,
|
||||
@@ -430,7 +439,7 @@ in more streamlined & auditable configuration rules – especially becau
|
||||
minimum of decision points to track.</p>
|
||||
</div>
|
||||
<div class="section" id="loop-shorthand">
|
||||
<h3>Loop Shorthand<a class="headerlink" href="#loop-shorthand" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Loop Shorthand<a class="headerlink" href="#loop-shorthand" title="Permalink to this headline">¶</a></h2>
|
||||
<p>To save some typing, repeated tasks can be written in short-hand like so:</p>
|
||||
<div class="highlight-python"><pre>- name: add user $item
|
||||
action: user name=$item state=present groups=wheel
|
||||
@@ -451,7 +460,7 @@ minimum of decision points to track.</p>
|
||||
manager transactions.</p>
|
||||
</div>
|
||||
<div class="section" id="selecting-files-and-templates-based-on-variables">
|
||||
<h3>Selecting Files And Templates Based On Variables<a class="headerlink" href="#selecting-files-and-templates-based-on-variables" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Selecting Files And Templates Based On Variables<a class="headerlink" href="#selecting-files-and-templates-based-on-variables" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Sometimes a configuration file you want to copy, or a template you will use may depend on a variable.
|
||||
The following construct selects the first available file appropriate for the variables of a given host,
|
||||
which is often much cleaner than putting a lot of if conditionals in a template.</p>
|
||||
@@ -465,7 +474,7 @@ CentOS and Debian:</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="asynchronous-actions-and-polling">
|
||||
<h3>Asynchronous Actions and Polling<a class="headerlink" href="#asynchronous-actions-and-polling" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Asynchronous Actions and Polling<a class="headerlink" href="#asynchronous-actions-and-polling" title="Permalink to this headline">¶</a></h2>
|
||||
<p>By default tasks in playbooks block, meaning the connections stay open
|
||||
until the task is done on each node. If executing playbooks with
|
||||
a small parallelism value (aka <tt class="docutils literal"><span class="pre">--forks</span></tt>), you may wish that long
|
||||
@@ -515,7 +524,7 @@ tasks even faster. This also increases the efficiency of polling.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="local-playbooks">
|
||||
<h3>Local Playbooks<a class="headerlink" href="#local-playbooks" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Local Playbooks<a class="headerlink" href="#local-playbooks" title="Permalink to this headline">¶</a></h2>
|
||||
<p>It may be useful to use a playbook locally, rather than by connecting over SSH. This can be useful
|
||||
for assuring the configuration of a system by putting a playbook on a crontab. This may also be used
|
||||
to run a playbook inside a OS installer, such as an Anaconda kickstart.</p>
|
||||
@@ -529,7 +538,7 @@ connection: local</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="turning-off-facts">
|
||||
<h3>Turning Off Facts<a class="headerlink" href="#turning-off-facts" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Turning Off Facts<a class="headerlink" href="#turning-off-facts" title="Permalink to this headline">¶</a></h2>
|
||||
<p>If you know you don’t need any fact data about your hosts, and know everything about your systems centrally, you
|
||||
can turn off fact gathering. This has advantages in scaling ansible in push mode with very large numbers of
|
||||
systems, mainly, or if you are using Ansible on experimental platforms. In any play, just do this:</p>
|
||||
@@ -538,7 +547,7 @@ systems, mainly, or if you are using Ansible on experimental platforms. In any
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="pull-mode-playbooks">
|
||||
<h3>Pull-Mode Playbooks<a class="headerlink" href="#pull-mode-playbooks" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Pull-Mode Playbooks<a class="headerlink" href="#pull-mode-playbooks" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The use of playbooks in local mode (above) is made extremely powerful with the addition of <cite>ansible-pull</cite>.
|
||||
A script for setting up ansible-pull is provided in the examples/playbooks directory of the source
|
||||
checkout.</p>
|
||||
@@ -550,7 +559,7 @@ the cron frequency, logging locations, and parameters to ansible-pull.</p>
|
||||
logs from ansible-pull runs would be an excellent way to gather and analyze remote logs from ansible-pull.</p>
|
||||
</div>
|
||||
<div class="section" id="style-points">
|
||||
<h3>Style Points<a class="headerlink" href="#style-points" title="Permalink to this headline">¶</a></h3>
|
||||
<h2>Style Points<a class="headerlink" href="#style-points" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Ansible playbooks are colorized. If you do not like this, set the ANSIBLE_NOCOLOR=1 environment variable.</p>
|
||||
<p>Ansible playbooks also look more impressive with cowsay installed, and we encourage installing this package.</p>
|
||||
<div class="admonition-see-also admonition seealso">
|
||||
@@ -576,7 +585,6 @@ logs from ansible-pull runs would be an excellent way to gather and analyze remo
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<br/>
|
||||
@@ -606,7 +614,7 @@ logs from ansible-pull runs would be an excellent way to gather and analyze remo
|
||||
</p>
|
||||
<p>
|
||||
© Copyright 2012 Michael DeHaan.<br/>
|
||||
Last updated on Aug 01, 2012.<br/>
|
||||
Last updated on Aug 02, 2012.<br/>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
Reference in New Issue
Block a user