Document --limit and range selection

This commit is contained in:
Michael DeHaan 2012-08-14 22:07:00 -04:00
parent cb0fb4c42f
commit 7bd6fde2a3
23 changed files with 202 additions and 181 deletions

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>
@ -208,15 +207,23 @@ also need:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">python-simplejson</span></tt></li>
</ul>
<p>(Note that even that&#8217;s not quite true. Ansible&#8217;s &#8220;raw&#8221; module (for executing commands in a quick and dirty way) and the copy module &#8211; some of the most basic features in ansible don&#8217;t even need that. So technically, you can use Ansible to install python-simplejson using the raw module, which then allows you to use everything else. That&#8217;s jumping ahead though.)</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Ansible&#8217;s &#8220;raw&#8221; module (for executing commands in a quick and dirty
way) and the copy module &#8211; some of the most basic features in
ansible &#8211; don&#8217;t even need that. So technically, you can use
Ansible to install python-simplejson using the raw module, which
then allows you to use everything else. (That&#8217;s jumping ahead
though.)</p>
</div>
</div>
<div class="section" id="python-2-6-epel-instructions-for-rhel-and-centos-5">
<h2>Python 2.6 EPEL instructions for RHEL and CentOS 5<a class="headerlink" href="#python-2-6-epel-instructions-for-rhel-and-centos-5" title="Permalink to this headline"></a></h2>
<p>These distributions don&#8217;t have Python 2.6 by default, but it is easily installable.</p>
<ul class="simple">
<li>If you have not already done so, <a class="reference external" href="http://fedoraproject.org/wiki/EPEL">configure EPEL</a></li>
<li>yum install python26 python26-PyYAML python26-paramiko python26-jinja2</li>
</ul>
<p>These distributions don&#8217;t have Python 2.6 by default, but it is easily
installable. If you have not already done so, <a class="reference external" href="http://fedoraproject.org/wiki/EPEL">configure EPEL</a></p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>yum install python26 python26-PyYAML python26-paramiko python26-jinja2
</pre></div>
</div>
</div>
<div class="section" id="getting-ansible">
<h2>Getting Ansible<a class="headerlink" href="#getting-ansible" title="Permalink to this headline"></a></h2>
@ -234,52 +241,61 @@ bugs and feature ideas.</p>
<h3>Running From Checkout<a class="headerlink" href="#running-from-checkout" title="Permalink to this headline"></a></h3>
<p>Ansible is trivially easy to run from a checkout, root permissions are not required
to use it:</p>
<div class="highlight-python"><pre>$ git clone git://github.com/ansible/ansible.git
$ cd ./ansible
$ source ./hacking/env-setup</pre>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>git clone git://github.com/ansible/ansible.git
<span class="nv">$ </span><span class="nb">cd</span> ./ansible
<span class="nv">$ </span><span class="nb">source</span> ./hacking/env-setup
</pre></div>
</div>
<p>You can optionally specify an inventory file (see <a class="reference internal" href="patterns.html"><em>Inventory &amp; Patterns</em></a>) other than /etc/ansible/hosts:</p>
<div class="highlight-python"><pre>$ echo "127.0.0.1" &gt; ~/ansible_hosts
$ export ANSIBLE_HOSTS=~/ansible_hosts</pre>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span><span class="nb">echo</span> <span class="s2">&quot;127.0.0.1&quot;</span> &gt; ~/ansible_hosts
<span class="nv">$ </span><span class="nb">export </span><span class="nv">ANSIBLE_HOSTS</span><span class="o">=</span>~/ansible_hosts
</pre></div>
</div>
<p>Now let&#8217;s test things:</p>
<div class="highlight-python"><pre>$ ansible all -m ping --ask-pass</pre>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible all -m ping --ask-pass
</pre></div>
</div>
</div>
<div class="section" id="make-install">
<h3>Make Install<a class="headerlink" href="#make-install" title="Permalink to this headline"></a></h3>
<p>If you are not working from a distribution where Ansible is packaged yet, you can install Ansible
using &#8220;make install&#8221;. This is done through <cite>python-distutils</cite>:</p>
<div class="highlight-python"><pre>$ git clone git://github.com/ansible/ansible.git
$ cd ./ansible
$ sudo make install</pre>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>git clone git://github.com/ansible/ansible.git
<span class="nv">$ </span><span class="nb">cd</span> ./ansible
<span class="nv">$ </span>sudo make install
</pre></div>
</div>
</div>
<div class="section" id="via-rpm">
<h3>Via RPM<a class="headerlink" href="#via-rpm" title="Permalink to this headline"></a></h3>
<p>RPMs for the last Ansible release are available for <a class="reference external" href="http://fedoraproject.org/wiki/EPEL">EPEL</a> 6 and currently supported
Fedora distributions. Ansible itself can manage earlier operating systems that contain python 2.4 or higher.</p>
<blockquote>
<div># install the epel-release RPM if needed on CentOS, RHEL, or Scientific Linux
$ sudo yum install ansible</div></blockquote>
<p>You can also use the <tt class="docutils literal"><span class="pre">make</span> <span class="pre">rpm</span></tt> command to
build an RPM you can distribute and install:</p>
<div class="highlight-python"><pre>$ git clone git://github.com/ansible/ansible.git
$ cd ./ansible
$ make rpm
$ sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-*.noarch.rpm</pre>
Fedora distributions. Ansible itself can manage earlier operating
systems that contain python 2.4 or higher.</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="c"># install the epel-release RPM if needed on CentOS, RHEL, or Scientific Linux</span>
<span class="nv">$ </span>sudo yum install ansible
</pre></div>
</div>
<p>You can also use the <tt class="docutils literal"><span class="pre">make</span> <span class="pre">rpm</span></tt> command to build an RPM you can
distribute and install:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>git clone git://github.com/ansible/ansible.git
<span class="nv">$ </span><span class="nb">cd</span> ./ansible
<span class="nv">$ </span>make rpm
<span class="nv">$ </span>sudo rpm -Uvh ~/rpmbuild/RPMS/noarch/ansible-*.noarch.rpm
</pre></div>
</div>
</div>
<div class="section" id="debian-gentoo-arch-others">
<h3>Debian, Gentoo, Arch, Others<a class="headerlink" href="#debian-gentoo-arch-others" title="Permalink to this headline"></a></h3>
<p>Ubuntu builds are available <a class="reference external" href="https://launchpad.net/~rquillo/+archive/ansible">in a PPA here</a></p>
<p>Debian/Ubuntu package recipes can also be built from the source checkout, run:</p>
<div class="highlight-python"><pre>make debian</pre>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>make debian
</pre></div>
</div>
<p>Gentoo eBuilds are available <a class="reference external" href="https://github.com/uu/ubuilds">on github here</a></p>
<p>An Arch PKGBUILD is available on <a class="reference external" href="https://aur.archlinux.org/packages.php?ID=58621">AUR</a>
If you have python3 installed on Arch, you probably want to symlink python to python2:</p>
<div class="highlight-python"><pre>sudo ln -sf /usr/bin/python2 /usr/bin/python</pre>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>sudo ln -sf /usr/bin/python2 /usr/bin/python
</pre></div>
</div>
<p>If you would like to package Ansible for Homebrew, BSD, or others,
please stop by the mailing list and say hi!</p>
@ -320,26 +336,29 @@ aserver.example.org
bserver.example.org</pre>
</div>
<p>Set up SSH agent to avoid retyping passwords:</p>
<div class="highlight-python"><pre>ssh-agent bash
ssh-add ~/.ssh/id_rsa</pre>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ssh-agent bash
<span class="nv">$ </span>ssh-add ~/.ssh/id_rsa
</pre></div>
</div>
<p>(Depending on your setup, you may wish to ansible&#8217;s &#8211;private-key-file option to specify a pem file instead)</p>
<p>Now ping all your nodes:</p>
<div class="highlight-python"><pre>ansible all -m ping</pre>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible all -m ping
</pre></div>
</div>
<p>If you want to access machines remotely as a different user than root, you will want to
specify the &#8216;-u&#8217; option to ansible. If you would like to access sudo mode, there are also flags to do that:</p>
<div class="highlight-python"><pre># as bruce
ansible all -m ping -u bruce
# as bruce, sudoing to root
ansible all -m ping -u bruce --sudo
# as bruce, sudoing to batman
ansible all -m ping -u bruce --sudo --sudo-user batman</pre>
<p>If you want to access machines remotely as a different user than root,
you will want to specify the &#8216;-u&#8217; option to ansible. If you would
like to access sudo mode, there are also flags to do that:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="c"># as bruce</span>
<span class="nv">$ </span>ansible all -m ping -u bruce
<span class="c"># as bruce, sudoing to root</span>
<span class="nv">$ </span>ansible all -m ping -u bruce --sudo
<span class="c"># as bruce, sudoing to batman</span>
<span class="nv">$ </span>ansible all -m ping -u bruce --sudo --sudo-user batman
</pre></div>
</div>
<p>Now run a live command on all of your nodes:</p>
<div class="highlight-python"><pre>ansible all -a "/bin/echo hello"</pre>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ansible all -a <span class="s2">&quot;/bin/echo hello&quot;</span>
</pre></div>
</div>
<p>Congratulations. You&#8217;ve just contacted your nodes with Ansible. It&#8217;s
now time to read some of the more real-world <a class="reference internal" href="examples.html"><em>Command Line</em></a>, and explore
@ -391,7 +410,7 @@ explore, but you already have a fully working infrastructure!</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>

View file

@ -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>

View file

@ -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>

View file

@ -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>
@ -150,8 +149,8 @@ s.parentNode.insertBefore(ga, s);
class="dropdown-toggle">Page</a>
<span class="localtoc"><ul>
<li><a class="reference internal" href="#">Ansible Modules</a><ul>
<li><a class="reference internal" href="#apt">apt</a></li>
<li><a class="reference internal" href="#apt-repository">apt_repository</a></li>
<li><a class="reference internal" href="#apt">apt</a></li>
<li><a class="reference internal" href="#assemble">assemble</a></li>
<li><a class="reference internal" href="#authorized-key">authorized_key</a></li>
<li><a class="reference internal" href="#command">command</a></li>
@ -236,8 +235,45 @@ not have to write modules in any particular language &#8211; you get to choose.<
playbooks, these modules can trigger &#8216;change events&#8217; in the form of notifying &#8216;handlers&#8217;
to run additional tasks.</p>
<p>Let&#8217;s see what&#8217;s available in the Ansible module library, out of the box:</p>
<div class="section" id="apt-repository">
<span id="id1"></span><h2>apt_repository<a class="headerlink" href="#apt-repository" title="Permalink to this headline"></a></h2>
<p class="versionadded">
<span class="versionmodified">New in version 0.7.</span></p>
<p>Manages apt repositores</p>
<table border="1" class="docutils">
<colgroup>
<col width="17%" />
<col width="9%" />
<col width="8%" />
<col width="66%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">parameter</th>
<th class="head">required</th>
<th class="head">default</th>
<th class="head">comments</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>repo</td>
<td>yes</td>
<td>&nbsp;</td>
<td>The repository name/value</td>
</tr>
<tr><td>state</td>
<td>no</td>
<td>present</td>
<td>&#8216;absent&#8217; or &#8216;present&#8217;</td>
</tr>
</tbody>
</table>
<p>Example action from Ansible <a class="reference internal" href="playbooks.html"><em>Playbooks</em></a>:</p>
<div class="highlight-python"><pre>apt_repository repo=ppa:nginx/stable
apt_repository repo='deb http://archive.canonical.com/ubuntu hardy partner'</pre>
</div>
</div>
<div class="section" id="apt">
<span id="id1"></span><h2>apt<a class="headerlink" href="#apt" title="Permalink to this headline"></a></h2>
<span id="id2"></span><h2>apt<a class="headerlink" href="#apt" title="Permalink to this headline"></a></h2>
<p>Manages apt-packages (such as for Debian/Ubuntu).</p>
<table border="1" class="docutils">
<colgroup>
@ -303,43 +339,6 @@ apt pkg=nginx state=latest default-release=squeeze-backports update-cache=yes
apt pkg=openjdk-6-jdk state=latest install-recommends=no</pre>
</div>
</div>
<div class="section" id="apt-repository">
<span id="id2"></span><h2>apt_repository<a class="headerlink" href="#apt-repository" title="Permalink to this headline"></a></h2>
<p class="versionadded">
<span class="versionmodified">New in version 0.7.</span></p>
<p>Manages apt repositores</p>
<table border="1" class="docutils">
<colgroup>
<col width="17%" />
<col width="9%" />
<col width="8%" />
<col width="66%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">parameter</th>
<th class="head">required</th>
<th class="head">default</th>
<th class="head">comments</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>repo</td>
<td>yes</td>
<td>&nbsp;</td>
<td>The repository name/value</td>
</tr>
<tr><td>state</td>
<td>no</td>
<td>present</td>
<td>&#8216;absent&#8217; or &#8216;present&#8217;</td>
</tr>
</tbody>
</table>
<p>Example action from Ansible <a class="reference internal" href="playbooks.html"><em>Playbooks</em></a>:</p>
<div class="highlight-python"><pre>apt_repository repo=ppa:nginx/stable
apt_repository repo='deb http://archive.canonical.com/ubuntu hardy partner'</pre>
</div>
</div>
<div class="section" id="assemble">
<span id="id3"></span><h2>assemble<a class="headerlink" href="#assemble" title="Permalink to this headline"></a></h2>
<p class="versionadded">
@ -912,6 +911,8 @@ configured in fstab. &#8216;absent&#8217;, and &#8216;present&#8217; only deal
</div>
<div class="section" id="mysql-db">
<span id="id15"></span><h2>mysql_db<a class="headerlink" href="#mysql-db" title="Permalink to this headline"></a></h2>
<p class="versionadded">
<span class="versionmodified">New in version 0.6.</span></p>
<p>Add or remove MySQL databases from a remote host.</p>
<p>Requires the MySQLdb Python package on the remote host. For Ubuntu, this is as easy as
apt-get install python-mysqldb.</p>
@ -977,6 +978,8 @@ finally fall back to using the MySQL default login of &#8216;root&#8217; with no
</div>
<div class="section" id="mysql-user">
<h2>mysql_user<a class="headerlink" href="#mysql-user" title="Permalink to this headline"></a></h2>
<p class="versionadded">
<span class="versionmodified">New in version 0.6.</span></p>
<p>Adds or removes a user from a MySQL database.</p>
<p>Requires the MySQLdb Python package on the remote host. For Ubuntu, this is as easy as
apt-get install python-mysqldb.</p>
@ -1129,7 +1132,9 @@ pip requirements=/srv/webapps/my_app/src/requirements.txt virtualenv=/srv/webapp
</div>
</div>
<div class="section" id="postgresql-db">
<h2>postgresql_db<a class="headerlink" href="#postgresql-db" title="Permalink to this headline"></a></h2>
<span id="id20"></span><h2>postgresql_db<a class="headerlink" href="#postgresql-db" title="Permalink to this headline"></a></h2>
<p class="versionadded">
<span class="versionmodified">New in version 0.6.</span></p>
<p>Add or remove PostgreSQL databases from a remote host.</p>
<p>The default authentication assumes that you are either logging in as or
sudo&#8217;ing to the postgres account on the host.</p>
@ -1186,7 +1191,9 @@ host before using this module.</p>
</div>
</div>
<div class="section" id="postgresql-user">
<h2>postgresql_user<a class="headerlink" href="#postgresql-user" title="Permalink to this headline"></a></h2>
<span id="id21"></span><h2>postgresql_user<a class="headerlink" href="#postgresql-user" title="Permalink to this headline"></a></h2>
<p class="versionadded">
<span class="versionmodified">New in version 0.6.</span></p>
<p>Add or remove PostgreSQL users (roles) from a remote host, and grant the users
access to an existing database.</p>
<p>The default authentication assumes that you are either logging in as or
@ -1254,7 +1261,7 @@ host before using this module.</p>
</div>
</div>
<div class="section" id="raw">
<span id="id20"></span><h2>raw<a class="headerlink" href="#raw" title="Permalink to this headline"></a></h2>
<span id="id22"></span><h2>raw<a class="headerlink" href="#raw" title="Permalink to this headline"></a></h2>
<p>Executes a low-down and dirty SSH command, not going through the module subsystem.</p>
<p>This is useful and should only be done in two cases. The first case is installing
python-simplejson on older (python 2.4 and before) hosts that need it as a dependency
@ -1269,7 +1276,7 @@ for this module.</p>
</div>
</div>
<div class="section" id="service">
<span id="id21"></span><h2>service<a class="headerlink" href="#service" title="Permalink to this headline"></a></h2>
<span id="id23"></span><h2>service<a class="headerlink" href="#service" title="Permalink to this headline"></a></h2>
<p>Controls services on remote machines.</p>
<table border="1" class="docutils">
<colgroup>
@ -1313,7 +1320,7 @@ service name=httpd state=reloaded</pre>
</div>
</div>
<div class="section" id="setup">
<span id="id22"></span><h2>setup<a class="headerlink" href="#setup" title="Permalink to this headline"></a></h2>
<span id="id24"></span><h2>setup<a class="headerlink" href="#setup" title="Permalink to this headline"></a></h2>
<p>This module is automatically called by playbooks to gather useful variables about remote hosts that can be used
in playbooks. It can also be executed directly by /usr/bin/ansible to check what variables are available
to a host.</p>
@ -1395,7 +1402,7 @@ on your remote systems.</p>
</div>
</div>
<div class="section" id="shell">
<span id="id23"></span><h2>shell<a class="headerlink" href="#shell" title="Permalink to this headline"></a></h2>
<span id="id25"></span><h2>shell<a class="headerlink" href="#shell" title="Permalink to this headline"></a></h2>
<p>The shell module takes the command name followed by a list of
arguments, space delimited. It is almost exactly like the command module
but runs the command through the user&#8217;s configured shell on the remote node.</p>
@ -1445,7 +1452,7 @@ your best judgement.</p>
</div>
</div>
<div class="section" id="supervisorctl">
<span id="id24"></span><h2>supervisorctl<a class="headerlink" href="#supervisorctl" title="Permalink to this headline"></a></h2>
<span id="id26"></span><h2>supervisorctl<a class="headerlink" href="#supervisorctl" title="Permalink to this headline"></a></h2>
<p class="versionadded">
<span class="versionmodified">New in version 0.7.</span></p>
<p>Manage the state of a program or group of programs running via Supervisord</p>
@ -1481,7 +1488,7 @@ your best judgement.</p>
</div>
</div>
<div class="section" id="template">
<span id="id25"></span><h2>template<a class="headerlink" href="#template" title="Permalink to this headline"></a></h2>
<span id="id27"></span><h2>template<a class="headerlink" href="#template" title="Permalink to this headline"></a></h2>
<p>Templates a file out to a remote server.</p>
<table border="1" class="docutils">
<colgroup>
@ -1521,7 +1528,7 @@ a relative or absolute path.</td>
</div>
</div>
<div class="section" id="user">
<span id="id26"></span><h2>user<a class="headerlink" href="#user" title="Permalink to this headline"></a></h2>
<span id="id28"></span><h2>user<a class="headerlink" href="#user" title="Permalink to this headline"></a></h2>
<p>Creates user accounts, manipulates existing user accounts, and removes user accounts.</p>
<table border="1" class="docutils">
<colgroup>
@ -1620,7 +1627,7 @@ user name=mdehaan state=absent force=yes</pre>
</div>
</div>
<div class="section" id="virt">
<span id="id27"></span><h2>virt<a class="headerlink" href="#virt" title="Permalink to this headline"></a></h2>
<span id="id29"></span><h2>virt<a class="headerlink" href="#virt" title="Permalink to this headline"></a></h2>
<p>Manages virtual machines supported by libvirt. Requires that libvirt be installed
on the managed machine.</p>
<table border="1" class="docutils">
@ -1680,7 +1687,7 @@ ansible host -m virt -a "command=virttype"</pre>
</div>
</div>
<div class="section" id="yum">
<span id="id28"></span><h2>yum<a class="headerlink" href="#yum" title="Permalink to this headline"></a></h2>
<span id="id30"></span><h2>yum<a class="headerlink" href="#yum" title="Permalink to this headline"></a></h2>
<p>Will install, upgrade, remove, and list packages with the yum package manager.</p>
<table border="1" class="docutils">
<colgroup>
@ -1778,7 +1785,7 @@ yum name=httpd state=installed</pre>
</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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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`

View file

@ -161,7 +161,6 @@ Documentation
api
moduledev
faq
glossary
who_uses_ansible

View file

@ -3,6 +3,8 @@
mount
`````
.. versionadded:: 0.6
The mount module controls active and configured mount points (fstab).
+--------------------+----------+---------+----------------------------------------------------------------------------+

View file

@ -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

View file

@ -1,6 +1,8 @@
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

View file

@ -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

View file

@ -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.

View file

@ -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>

File diff suppressed because one or more lines are too long

View file

@ -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>