mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
Document --limit and range selection
This commit is contained in:
parent
cb0fb4c42f
commit
7bd6fde2a3
23 changed files with 202 additions and 181 deletions
|
@ -140,7 +140,6 @@ s.parentNode.insertBefore(ga, s);
|
|||
<li class="toctree-l1"><a class="reference internal" href="api.html">API & 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’s not quite true. Ansible’s “raw” module (for executing commands in a quick and dirty way) and the copy module – some of the most basic features in ansible don’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’s jumping ahead though.)</p>
|
||||
<div class="admonition note">
|
||||
<p class="first admonition-title">Note</p>
|
||||
<p class="last">Ansible’s “raw” module (for executing commands in a quick and dirty
|
||||
way) and the copy module – some of the most basic features in
|
||||
ansible – don’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’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’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’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 & Patterns</em></a>) other than /etc/ansible/hosts:</p>
|
||||
<div class="highlight-python"><pre>$ echo "127.0.0.1" > ~/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">"127.0.0.1"</span> > ~/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’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 “make install”. 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’s –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 ‘-u’ 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 ‘-u’ 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">"/bin/echo hello"</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Congratulations. You’ve just contacted your nodes with Ansible. It’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>
|
||||
© Copyright 2012 Michael DeHaan.<br/>
|
||||
Last updated on Aug 10, 2012.<br/>
|
||||
Last updated on Aug 14, 2012.<br/>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue