@@ -386,10 +386,12 @@ also works with <tt class="docutils literal"><span class="pre">ansible-playbook<
</pre></div>
</div>
<p>Now let’s talk about range selection. Suppose you have 1000 servers in group ‘datacenter’, but only want to target one at a time. This is also easy:</p>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible webservers<spanclass="o">[</span>0-100<spanclass="o">]</span> -m <spanclass="nb">command</span> -a <spanclass="s2">"/bin/foo xyz"</span>
<spanclass="nv">$ </span>ansible webservers<spanclass="o">[</span>101-200<spanclass="o">]</span> -m <spanclass="nb">command</span> -a <spanclass="s2">"/bin/foo xyz"</span>
<divclass="highlight-bash"><divclass="highlight"><pre><spanclass="nv">$ </span>ansible webservers<spanclass="o">[</span>0-99<spanclass="o">]</span> -m <spanclass="nb">command</span> -a <spanclass="s2">"/bin/foo xyz"</span>
<spanclass="nv">$ </span>ansible webservers<spanclass="o">[</span>100-199<spanclass="o">]</span> -m <spanclass="nb">command</span> -a <spanclass="s2">"/bin/foo xyz"</span>
</pre></div>
</div>
<p>This will select the first 100, then the second 100, host entries in the webservers group. (It does not matter
what their names or IP addresses are).</p>
<p>Both of these methods can be used at the same time, and ranges can also be passed to the –limit parameter.</p>
@@ -578,6 +579,26 @@ the cron frequency, logging locations, and parameters to ansible-pull.</p>
<p>This is useful both for extreme scale-out as well as periodic remediation. Usage of the ‘fetch’ module to retrieve
logs from ansible-pull runs would be an excellent way to gather and analyze remote logs from ansible-pull.</p>
</div>
<divclass="section"id="register-variables">
<h2>Register Variables<aclass="headerlink"href="#register-variables"title="Permalink to this headline">¶</a></h2>
<pclass="versionadded">
<spanclass="versionmodified">New in version 0.7.</span></p>
<p>Often in a playbook it may be useful to store the result of a given command in a variable and access
it later. Use of the command module in this way can in many ways eliminate the need to write site specific facts, for
instance, you could test for the existance of a particular program.</p>
<p>The ‘register’ keyword decides what variable to save a result in. The resulting variables can be used in templates, action lines, or only_if statements. It looks like this (in an obviously trivial example):</p>
<divclass="highlight-python"><pre>- name: test playbook
@@ -437,6 +437,29 @@ the cron frequency, logging locations, and parameters to ansible-pull.
This is useful both for extreme scale-out as well as periodic remediation. Usage of the 'fetch' module to retrieve
logs from ansible-pull runs would be an excellent way to gather and analyze remote logs from ansible-pull.
Register Variables
``````````````````
.. versionadded:: 0.7
Often in a playbook it may be useful to store the result of a given command in a variable and access
it later. Use of the command module in this way can in many ways eliminate the need to write site specific facts, for
instance, you could test for the existance of a particular program.
The 'register' keyword decides what variable to save a result in. The resulting variables can be used in templates, action lines, or only_if statements. It looks like this (in an obviously trivial example)::