Commit 7bd6fde2 by Michael DeHaan

Document --limit and range selection

parent cb0fb4c4
......@@ -140,7 +140,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -290,7 +289,7 @@ languages:
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -140,7 +140,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1 current"><a class="current reference internal" href="">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -470,7 +469,7 @@ e.g.
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -140,7 +140,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -341,7 +340,7 @@ different variables to different geographies.</p>
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -140,7 +140,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -157,6 +156,7 @@ s.parentNode.insertBefore(ga, s);
<li><a class="reference internal" href="#deploying-from-source-control">Deploying From Source Control</a></li>
<li><a class="reference internal" href="#managing-services">Managing Services</a></li>
<li><a class="reference internal" href="#time-limited-background-operations">Time Limited Background Operations</a></li>
<li><a class="reference internal" href="#limiting-selected-hosts">Limiting Selected Hosts</a></li>
</ul>
</li>
</ul>
......@@ -261,32 +261,8 @@ optionally use them as template sources.</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible atlanta -m copy -a <span class="s2">&quot;src=/etc/hosts dest=/tmp/hosts&quot;</span>
</pre></div>
</div>
<p>To use templating, first run the setup module to put the template
variables you would like to use on the remote host. Then use the
template module to write the files using those templates.</p>
<p>Templates are written in <a class="reference external" href="http://jinja.pocoo.org/docs/">Jinja2</a>
format. <a class="reference internal" href="playbooks.html"><em>Playbooks</em></a> will run the setup module for you, making
this even simpler:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible webservers -m setup -a <span class="s2">&quot;favcolor=red ntp_server=192.168.1.1&quot;</span>
<span class="nv">$ </span>ansible webservers -m template -a <span class="s2">&quot;src=/srv/motd.j2 dest=/etc/motd&quot;</span>
<span class="nv">$ </span>ansible webservers -m template -a <span class="s2">&quot;src=/srv/ntp.j2 dest=/etc/ntp.conf&quot;</span>
</pre></div>
</div>
<p>Ansible variables are used in templates by using the name surrounded
by double curly-braces. Ansible provides some <em>facts</em> about the
system being managed automatically in playbooks or when the setup
module is run manually. If facter or ohai were installed on the
remote machine, variables from those programs can be accessed too,
using the appropriate prefix:</p>
<div class="highlight-django"><div class="highlight"><pre><span class="x">This is an Ansible variable: </span><span class="cp">{{</span> <span class="nv">favcolor</span> <span class="cp">}}</span><span class="x"></span>
<span class="x">This is an Ansible fact: </span><span class="cp">{{</span> <span class="nv">ansible_hostname</span> <span class="cp">}}</span><span class="x"></span>
<span class="x">This is a facter fact: </span><span class="cp">{{</span> <span class="nv">facter_hostname</span> <span class="cp">}}</span><span class="x"></span>
<span class="x">This is an ohai fact: </span><span class="cp">{{</span> <span class="nv">ohai_foo</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
</div>
<p>Using the Ansible facts is generally preferred as that way you can avoid a dependency
on ruby. If you want to use facter instead, you will also need rubygem-json because
the facter packages may forget this as a dependency.</p>
<p>If you use playbooks, you can also take advantage of the template module,
which takes this another step further.</p>
<p>The <tt class="docutils literal"><span class="pre">file</span></tt> module allows changing ownership and permissions on files. These
same options can be passed directly to the <tt class="docutils literal"><span class="pre">copy</span></tt> or <tt class="docutils literal"><span class="pre">template</span></tt> modules as well:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible webservers -m file -a <span class="s2">&quot;dest=/srv/foo/a.txt mode=600&quot;</span>
......@@ -393,6 +369,28 @@ the remote nodes will be terminated.</p>
backgrounded. Typically you&#8217;ll be backgrounding long-running
shell commands or software upgrades only. <a class="reference internal" href="playbooks.html"><em>Playbooks</em></a> also support polling, and have
a simplified syntax for this.</p>
</div>
<div class="section" id="limiting-selected-hosts">
<h2>Limiting Selected Hosts<a class="headerlink" href="#limiting-selected-hosts" title="Permalink to this headline"></a></h2>
<p class="versionadded">
<span class="versionmodified">New in version 0.7.</span></p>
<p>What hosts you select to manage can be additionally constrained by using the &#8216;&#8211;limit&#8217; parameter or
by using &#8216;batch&#8217; (or &#8216;range&#8217;) selectors.</p>
<p>As mentioned above, patterns can be strung together to select hosts in more than one group:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible webservers:dbservers -m <span class="nb">command</span> -a <span class="s2">&quot;/bin/foo xyz&quot;</span>
</pre></div>
</div>
<p>This is an &#8220;or&#8221; condition. If you want to further constrain the selection, use &#8211;limit, which
also works with <tt class="docutils literal"><span class="pre">ansible-playbook</span></tt>:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible webservers:dbservers -m <span class="nb">command</span> -a <span class="s2">&quot;/bin/foo xyz&quot;</span> region
</pre></div>
</div>
<p>Now let&#8217;s talk about range selection. Suppose you have 1000 servers in group &#8216;datacenter&#8217;, but only want to target one at a time. This is also easy:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible webservers<span class="o">[</span>0-100<span class="o">]</span> -m <span class="nb">command</span> -a <span class="s2">&quot;/bin/foo xyz&quot;</span>
<span class="nv">$ </span>ansible webservers<span class="o">[</span>101-200<span class="o">]</span> -m <span class="nb">command</span> -a <span class="s2">&quot;/bin/foo xyz&quot;</span>
</pre></div>
</div>
<p>Both of these methods can be used at the same time, and ranges can also be passed to the &#8211;limit parameter.</p>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
......@@ -437,7 +435,7 @@ a simplified syntax for this.</p>
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -27,7 +27,7 @@
<script type="text/javascript" src="_static/bootstrap-scrollspy.js"></script>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="top" title="Ansible - SSH-Based Configuration Management &amp; Deployment" href="index.html" />
<link rel="next" title="Glossary" href="glossary.html" />
<link rel="next" title="Who Uses Ansible" href="who_uses_ansible.html" />
<link rel="prev" title="Module Development" href="moduledev.html" />
<script type="text/javascript">
(function () {
......@@ -140,7 +140,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -410,7 +409,7 @@ tasks &#8211; whether for a QA sytem, build system, or anything you can think of
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -138,7 +138,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -205,7 +204,7 @@ s.parentNode.insertBefore(ga, s);
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -139,7 +139,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -381,7 +380,6 @@ Puppet Labs, and is now with <a class="reference external" href="http://rpath.co
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</div>
......@@ -415,7 +413,7 @@ Puppet Labs, and is now with <a class="reference external" href="http://rpath.co
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -140,7 +140,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -512,7 +511,7 @@ the program. Stop by the mailing list to inquire about requirements.</p>
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -140,7 +140,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -387,7 +386,7 @@ Ansible 0.7. Ansible 0.6 includes a <a class="reference external" href="https:/
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -140,7 +140,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -547,7 +546,7 @@ package is installed. Try it!</p>
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -140,7 +140,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -635,7 +634,7 @@ logs from ansible-pull runs would be an excellent way to gather and analyze remo
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -89,35 +89,8 @@ To transfer a file directly to many different servers::
$ ansible atlanta -m copy -a "src=/etc/hosts dest=/tmp/hosts"
To use templating, first run the setup module to put the template
variables you would like to use on the remote host. Then use the
template module to write the files using those templates.
Templates are written in `Jinja2 <http://jinja.pocoo.org/docs/>`_
format. :doc:`playbooks` will run the setup module for you, making
this even simpler::
$ ansible webservers -m setup -a "favcolor=red ntp_server=192.168.1.1"
$ ansible webservers -m template -a "src=/srv/motd.j2 dest=/etc/motd"
$ ansible webservers -m template -a "src=/srv/ntp.j2 dest=/etc/ntp.conf"
Ansible variables are used in templates by using the name surrounded
by double curly-braces. Ansible provides some *facts* about the
system being managed automatically in playbooks or when the setup
module is run manually. If facter or ohai were installed on the
remote machine, variables from those programs can be accessed too,
using the appropriate prefix:
.. code-block:: django
This is an Ansible variable: {{ favcolor }}
This is an Ansible fact: {{ ansible_hostname }}
This is a facter fact: {{ facter_hostname }}
This is an ohai fact: {{ ohai_foo }}
Using the Ansible facts is generally preferred as that way you can avoid a dependency
on ruby. If you want to use facter instead, you will also need rubygem-json because
the facter packages may forget this as a dependency.
If you use playbooks, you can also take advantage of the template module,
which takes this another step further.
The ``file`` module allows changing ownership and permissions on files. These
same options can be passed directly to the ``copy`` or ``template`` modules as well::
......@@ -234,6 +207,34 @@ backgrounded. Typically you'll be backgrounding long-running
shell commands or software upgrades only. :doc:`playbooks` also support polling, and have
a simplified syntax for this.
Limiting Selected Hosts
```````````````````````
.. versionadded:: 0.7
What hosts you select to manage can be additionally constrained by using the '--limit' parameter or
by using 'batch' (or 'range') selectors.
As mentioned above, patterns can be strung together to select hosts in more than one group::
$ ansible webservers:dbservers -m command -a "/bin/foo xyz"
This is an "or" condition. If you want to further constrain the selection, use --limit, which
also works with ``ansible-playbook``::
$ ansible webservers:dbservers -m command -a "/bin/foo xyz" region
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::
$ ansible webservers[0-99] -m command -a "/bin/foo xyz"
$ ansible webservers[100-199] -m command -a "/bin/foo xyz"
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).
Both of these methods can be used at the same time, and ranges can also be passed to the --limit parameter.
.. seealso::
:doc:`modules`
......
......@@ -161,7 +161,6 @@ Documentation
api
moduledev
faq
glossary
who_uses_ansible
......
......@@ -3,6 +3,8 @@
mount
`````
.. versionadded:: 0.6
The mount module controls active and configured mount points (fstab).
+--------------------+----------+---------+----------------------------------------------------------------------------+
......
......@@ -3,6 +3,8 @@
mysql_db
````````
.. versionadded:: 0.6
Add or remove MySQL databases from a remote host.
Requires the MySQLdb Python package on the remote host. For Ubuntu, this is as easy as
......
mysql_user
``````````
.. versionadded:: 0.6
Adds or removes a user from a MySQL database.
Requires the MySQLdb Python package on the remote host. For Ubuntu, this is as easy as
......
......@@ -3,6 +3,8 @@
postgresql_db
`````````````
.. versionadded:: 0.6
Add or remove PostgreSQL databases from a remote host.
The default authentication assumes that you are either logging in as or
......
......@@ -3,6 +3,8 @@
postgresql_user
```````````````
.. versionadded:: 0.6
Add or remove PostgreSQL users (roles) from a remote host, and grant the users
access to an existing database.
......
......@@ -144,7 +144,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1"><a class="reference internal" href="who_uses_ansible.html">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -222,7 +221,7 @@ s.parentNode.insertBefore(ga, s);
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
......@@ -27,7 +27,7 @@
<script type="text/javascript" src="_static/bootstrap-scrollspy.js"></script>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="top" title="Ansible - SSH-Based Configuration Management &amp; Deployment" href="index.html" />
<link rel="prev" title="Glossary" href="glossary.html" />
<link rel="prev" title="FAQ" href="faq.html" />
<script type="text/javascript">
(function () {
/**
......@@ -139,7 +139,6 @@ s.parentNode.insertBefore(ga, s);
<li class="toctree-l1"><a class="reference internal" href="api.html">API &amp; Integrations</a></li>
<li class="toctree-l1"><a class="reference internal" href="moduledev.html">Module Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Who Uses Ansible</a></li>
</ul>
</span>
......@@ -264,7 +263,7 @@ s.parentNode.insertBefore(ga, s);
</p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Aug 10, 2012.<br/>
Last updated on Aug 14, 2012.<br/>
</p>
</div>
</footer>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment