Remove some note callouts on the example page and inline the commentary so it's easier to read.

pull/1256/head
Michael DeHaan 13 years ago
parent 87ab7d76af
commit 5327f52c3c

@ -163,41 +163,40 @@ s.parentNode.insertBefore(ga, s);
<div class="section" id="command-line-examples"> <div class="section" id="command-line-examples">
<h1>Command Line Examples<a class="headerlink" href="#command-line-examples" title="Permalink to this headline"></a></h1> <h1>Command Line Examples<a class="headerlink" href="#command-line-examples" title="Permalink to this headline"></a></h1>
<p>The following examples show how to use <cite>/usr/bin/ansible</cite> for running ad-hoc tasks. <p>The following examples show how to use <cite>/usr/bin/ansible</cite> for running ad-hoc tasks.
Start here. For configuration management and deployments, you&#8217;ll want to pick up on Start here.</p>
using <cite>/usr/bin/ansible-playbook</cite> &#8211; the concepts port over directly.</p> <p>For configuration management and deployments, you&#8217;ll want to pick up on
using <cite>/usr/bin/ansible-playbook</cite> &#8211; the concepts port over directly.
(See <a class="reference internal" href="playbooks.html"><em>Playbooks</em></a> for more information about those)</p>
<div class="section" id="parallelism-and-shell-commands"> <div class="section" id="parallelism-and-shell-commands">
<h2>Parallelism and Shell Commands<a class="headerlink" href="#parallelism-and-shell-commands" title="Permalink to this headline"></a></h2> <h2>Parallelism and Shell Commands<a class="headerlink" href="#parallelism-and-shell-commands" title="Permalink to this headline"></a></h2>
<p>Let&#8217;s use ansible&#8217;s command line tool to reboot all web servers in Atlanta, 10 at a time:</p> <p>Let&#8217;s use ansible&#8217;s command line tool to reboot all web servers in Atlanta, 10 at a time. First, let&#8217;s
set up SSH-agent so it can remember our credentials:</p>
<div class="highlight-python"><pre>ssh-agent bash <div class="highlight-python"><pre>ssh-agent bash
ssh-add ~/.ssh/id_rsa.pub ssh-add ~/.ssh/id_rsa.pub</pre>
</div>
ansible atlanta -a "/sbin/reboot" -f 10</pre> <p>Now to run the command on all servers in a group, in this case, &#8216;atlanta&#8217;:</p>
</div> <div class="highlight-python"><pre>ansible atlanta -a "/sbin/reboot" -f 10</pre>
<p>The -f 10 specifies the usage of 10 simultaneous processes.</p> </div>
<div class="admonition note"> <p>If you didn&#8217;t read about patterns and groups yet, go back and read <a class="reference internal" href="patterns.html"><em>The Inventory File, Patterns, and Groups</em></a>.</p>
<p class="first admonition-title">Note</p> <p>The -f 10 in the above specifies the usage of 10 simultaneous processes. Normally commands also take
<p class="last">-m does not always have to be specified to /usr/bin/ansible because &#8216;command&#8217; is the default ansible module</p> a <cite>-m</cite> for module name, but the default module name is &#8216;command&#8217;, so we didn&#8217;t need to specify that
</div> here. We&#8217;ll use <cite>-m</cite> later to run some other <a class="reference internal" href="modules.html"><em>Ansible Modules</em></a>.</p>
<p>If we want to execute a module using the shell, we can avoid using absolute paths, and can also include <p>The command module requires absolute paths and does not support shell variables. If we want to
pipe and redirection operators. Read more about the differences on the <a class="reference internal" href="modules.html"><em>Ansible Modules</em></a> page. The shell execute a module using the shell, we can do those things, and also use pipe and redirection operators.
Read more about the differences on the <a class="reference internal" href="modules.html"><em>Ansible Modules</em></a> page. The shell
module looks like this:</p> module looks like this:</p>
<div class="highlight-python"><pre>ansible raleigh -m shell -a "echo \\$TERM"</pre> <div class="highlight-python"><pre>ansible raleigh -m shell -a "echo \\$TERM"</pre>
</div> </div>
<div class="admonition note"> <p>When running any command with the ansible &#8220;ad hoc&#8221; CLI (as opposed to playbooks), pay particular attention
<p class="first admonition-title">Note</p> to shell quoting rules, so the shell doesn&#8217;t eat a variable before it gets passed to Ansible.</p>
<p class="last">When using ansible to run commands, and in particular the shell module, be careful of shell quoting rules.</p> <p>So far we&#8217;ve been demoing simple command execution, but most ansible modules usually do not work like
</div> simple scripts. They make the remote system look like you state, and run the commands necessary to
<div class="admonition note"> get it there. This is commonly referred to as &#8216;idempotence&#8217;, and is a core design goal of ansible.
<p class="first admonition-title">Note</p> However, we also recognize that running ad-hoc commands is equally imporant, so Ansible easily supports both.</p>
<p class="last">Note that other than the command <a class="reference internal" href="modules.html"><em>Ansible Modules</em></a>, ansible modules usually do
not work like simple scripts. They make the remote system look like
you state, and run the commands necessary to get it there. This
is commonly referred to as &#8216;idempotence&#8217;, and is a core design goal of ansible. However, we also
recognize that running ad-hoc commands is equally imporant, so Ansible easily supports both.</p>
</div>
</div> </div>
<div class="section" id="file-transfer-templating"> <div class="section" id="file-transfer-templating">
<h2>File Transfer &amp; Templating<a class="headerlink" href="#file-transfer-templating" title="Permalink to this headline"></a></h2> <h2>File Transfer &amp; Templating<a class="headerlink" href="#file-transfer-templating" title="Permalink to this headline"></a></h2>
<p>Here&#8217;s another use case for the <cite>/usr/bin/ansible</cite> command line.</p>
<p>Ansible can SCP lots of files to multiple machines in parallel, and <p>Ansible can SCP lots of files to multiple machines in parallel, and
optionally use them as template sources.</p> optionally use them as template sources.</p>
<p>To just transfer a file directly to many different servers:</p> <p>To just transfer a file directly to many different servers:</p>
@ -248,7 +247,7 @@ ansible webservers -m file -a "dest=/srv/foo/b.txt mode=600 owner=mdehaan group=
<div class="highlight-python"><pre>ansible-webservers -m yum -a "pkg=acme state=removed"</pre> <div class="highlight-python"><pre>ansible-webservers -m yum -a "pkg=acme state=removed"</pre>
</div> </div>
<p>Currently Ansible only has a module for managing packages with yum. You can install <p>Currently Ansible only has a module for managing packages with yum. You can install
for other package manages using the command module or contribute a module for other packages for now using the command module or (better!) contribute a module
for other package managers. Stop by the mailing list for info/details.</p> for other package managers. Stop by the mailing list for info/details.</p>
</div> </div>
<div class="section" id="users-and-groups"> <div class="section" id="users-and-groups">
@ -264,7 +263,7 @@ ansible all -m user -a "name=foo state=absent"</pre>
<div class="section" id="deploying-from-source-control"> <div class="section" id="deploying-from-source-control">
<h2>Deploying From Source Control<a class="headerlink" href="#deploying-from-source-control" title="Permalink to this headline"></a></h2> <h2>Deploying From Source Control<a class="headerlink" href="#deploying-from-source-control" title="Permalink to this headline"></a></h2>
<p>Deploy your webapp straight from git:</p> <p>Deploy your webapp straight from git:</p>
<div class="highlight-python"><pre>ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD"</pre> <div class="highlight-python"><pre>ansible webservers -m git -a "repo=git://foo.example.org/repo.git dest=/srv/myapp version=HEAD"</pre>
</div> </div>
<p>Since ansible modules can notify change handlers (see <p>Since ansible modules can notify change handlers (see
<a class="reference internal" href="playbooks.html"><em>Playbooks</em></a>) it is possible to tell ansible to run specific tasks <a class="reference internal" href="playbooks.html"><em>Playbooks</em></a>) it is possible to tell ansible to run specific tasks

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ansible-playbook</title><link rel="stylesheet" href="./docbook-xsl.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><div xml:lang="en" class="refentry" title="ansible-playbook" lang="en"><a id="id554898"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ansible-playbook — run an ansible playbook</p></div><div class="refsynopsisdiv" title="Synopsis"><a id="_synopsis"></a><h2>Synopsis</h2><p>ansible-playbook &lt;filename.yml&gt; … [options]</p></div><div class="refsect1" title="DESCRIPTION"><a id="_description"></a><h2>DESCRIPTION</h2><p><span class="strong"><strong>Ansible playbooks</strong></span> are a configuration and multinode deployment system. Ansible-playbook is the tool <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ansible-playbook</title><link rel="stylesheet" href="./docbook-xsl.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><div xml:lang="en" class="refentry" title="ansible-playbook" lang="en"><a id="id330881"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ansible-playbook — run an ansible playbook</p></div><div class="refsynopsisdiv" title="Synopsis"><a id="_synopsis"></a><h2>Synopsis</h2><p>ansible-playbook &lt;filename.yml&gt; … [options]</p></div><div class="refsect1" title="DESCRIPTION"><a id="_description"></a><h2>DESCRIPTION</h2><p><span class="strong"><strong>Ansible playbooks</strong></span> are a configuration and multinode deployment system. Ansible-playbook is the tool
used to run them. See the project home page (link below) for more information.</p></div><div class="refsect1" title="ARGUMENTS"><a id="_arguments"></a><h2>ARGUMENTS</h2><div class="variablelist"><dl><dt><span class="term"> used to run them. See the project home page (link below) for more information.</p></div><div class="refsect1" title="ARGUMENTS"><a id="_arguments"></a><h2>ARGUMENTS</h2><div class="variablelist"><dl><dt><span class="term">
<span class="strong"><strong>filename.yml</strong></span> <span class="strong"><strong>filename.yml</strong></span>
</span></dt><dd> </span></dt><dd>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ansible</title><link rel="stylesheet" href="./docbook-xsl.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><div xml:lang="en" class="refentry" title="ansible" lang="en"><a id="id575958"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ansible — run a command somewhere else</p></div><div class="refsynopsisdiv" title="Synopsis"><a id="_synopsis"></a><h2>Synopsis</h2><p>ansible &lt;host-pattern&gt; [-f forks] [-m module_name] [-a args]</p></div><div class="refsect1" title="DESCRIPTION"><a id="_description"></a><h2>DESCRIPTION</h2><p><span class="strong"><strong>Ansible</strong></span> is an extra-simple tool/framework/API for doing 'remote things' over <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ansible</title><link rel="stylesheet" href="./docbook-xsl.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><div xml:lang="en" class="refentry" title="ansible" lang="en"><a id="id372046"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ansible — run a command somewhere else</p></div><div class="refsynopsisdiv" title="Synopsis"><a id="_synopsis"></a><h2>Synopsis</h2><p>ansible &lt;host-pattern&gt; [-f forks] [-m module_name] [-a args]</p></div><div class="refsect1" title="DESCRIPTION"><a id="_description"></a><h2>DESCRIPTION</h2><p><span class="strong"><strong>Ansible</strong></span> is an extra-simple tool/framework/API for doing 'remote things' over
SSH.</p></div><div class="refsect1" title="ARGUMENTS"><a id="_arguments"></a><h2>ARGUMENTS</h2><div class="variablelist"><dl><dt><span class="term"> SSH.</p></div><div class="refsect1" title="ARGUMENTS"><a id="_arguments"></a><h2>ARGUMENTS</h2><div class="variablelist"><dl><dt><span class="term">
<span class="strong"><strong>host-pattern</strong></span> <span class="strong"><strong>host-pattern</strong></span>
</span></dt><dd> </span></dt><dd>

@ -2,44 +2,52 @@ Command Line Examples
===================== =====================
The following examples show how to use `/usr/bin/ansible` for running ad-hoc tasks. The following examples show how to use `/usr/bin/ansible` for running ad-hoc tasks.
Start here. For configuration management and deployments, you'll want to pick up on Start here.
using `/usr/bin/ansible-playbook` -- the concepts port over directly.
For configuration management and deployments, you'll want to pick up on
using `/usr/bin/ansible-playbook` -- the concepts port over directly.
(See :doc:`playbooks` for more information about those)
Parallelism and Shell Commands Parallelism and Shell Commands
`````````````````````````````` ``````````````````````````````
Let's use ansible's command line tool to reboot all web servers in Atlanta, 10 at a time:: Let's use ansible's command line tool to reboot all web servers in Atlanta, 10 at a time. First, let's
set up SSH-agent so it can remember our credentials::
ssh-agent bash ssh-agent bash
ssh-add ~/.ssh/id_rsa.pub ssh-add ~/.ssh/id_rsa.pub
Now to run the command on all servers in a group, in this case, 'atlanta'::
ansible atlanta -a "/sbin/reboot" -f 10 ansible atlanta -a "/sbin/reboot" -f 10
The -f 10 specifies the usage of 10 simultaneous processes. If you didn't read about patterns and groups yet, go back and read :doc:`patterns`.
.. note:: The -f 10 in the above specifies the usage of 10 simultaneous processes. Normally commands also take
-m does not always have to be specified to /usr/bin/ansible because 'command' is the default ansible module a `-m` for module name, but the default module name is 'command', so we didn't need to specify that
here. We'll use `-m` later to run some other :doc:`modules`.
If we want to execute a module using the shell, we can avoid using absolute paths, and can also include The command module requires absolute paths and does not support shell variables. If we want to
pipe and redirection operators. Read more about the differences on the :doc:`modules` page. The shell execute a module using the shell, we can do those things, and also use pipe and redirection operators.
Read more about the differences on the :doc:`modules` page. The shell
module looks like this:: module looks like this::
ansible raleigh -m shell -a "echo \\$TERM" ansible raleigh -m shell -a "echo \\$TERM"
.. note:: When running any command with the ansible "ad hoc" CLI (as opposed to playbooks), pay particular attention
When using ansible to run commands, and in particular the shell module, be careful of shell quoting rules. to shell quoting rules, so the shell doesn't eat a variable before it gets passed to Ansible.
So far we've been demoing simple command execution, but most ansible modules usually do not work like
simple scripts. They make the remote system look like you state, and run the commands necessary to
get it there. This is commonly referred to as 'idempotence', and is a core design goal of ansible.
However, we also recognize that running ad-hoc commands is equally imporant, so Ansible easily supports both.
.. note::
Note that other than the command :doc:`modules`, ansible modules usually do
not work like simple scripts. They make the remote system look like
you state, and run the commands necessary to get it there. This
is commonly referred to as 'idempotence', and is a core design goal of ansible. However, we also
recognize that running ad-hoc commands is equally imporant, so Ansible easily supports both.
File Transfer & Templating File Transfer & Templating
`````````````````````````` ``````````````````````````
Here's another use case for the `/usr/bin/ansible` command line.
Ansible can SCP lots of files to multiple machines in parallel, and Ansible can SCP lots of files to multiple machines in parallel, and
optionally use them as template sources. optionally use them as template sources.
@ -104,7 +112,7 @@ Ensure a package is not installed::
ansible-webservers -m yum -a "pkg=acme state=removed" ansible-webservers -m yum -a "pkg=acme state=removed"
Currently Ansible only has a module for managing packages with yum. You can install Currently Ansible only has a module for managing packages with yum. You can install
for other package manages using the command module or contribute a module for other packages for now using the command module or (better!) contribute a module
for other package managers. Stop by the mailing list for info/details. for other package managers. Stop by the mailing list for info/details.
Users and Groups Users and Groups
@ -125,7 +133,7 @@ Deploying From Source Control
Deploy your webapp straight from git:: Deploy your webapp straight from git::
ansible webservers -m git -a "repo=git://foo dest=/srv/myapp version=HEAD" ansible webservers -m git -a "repo=git://foo.example.org/repo.git dest=/srv/myapp version=HEAD"
Since ansible modules can notify change handlers (see Since ansible modules can notify change handlers (see
:doc:`playbooks`) it is possible to tell ansible to run specific tasks :doc:`playbooks`) it is possible to tell ansible to run specific tasks

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save