ansible webservers -m command -a "/sbin/reboot -t now"</pre>
</div>
<p>Each module supports taking arguments. Nearly all modules take <ttclass="docutils literal"><spanclass="pre">key=value</span></tt>
arguments, space delimited. Some modules take
no arguments, and the command/shell modules simply take the string
of the command you want to run.</p>
arguments, space delimited. Some modules take no arguments, and the
command/shell modules simply take the string of the command you want to run.</p>
<p>From playbooks, Ansible modules are executed in a very similar way:</p>
<divclass="highlight-python"><pre>- name: reboot the servers
action: command /sbin/reboot -t now</pre>
@ -229,34 +228,56 @@ noted, any given module does support change hooks.</p>
<divclass="section"id="apt">
<spanid="id1"></span><h2>apt<aclass="headerlink"href="#apt"title="Permalink to this headline">¶</a></h2>
<p>Manages apt-packages (such as for Debian/Ubuntu).</p>
<p><em>pkg</em>:</p>
<ulclass="simple">
<li>A package name or package specifier with version, like <cite>foo</cite>, or <cite>foo=1.0</cite> to install a specific version of the foo package.</li>
</ul>
<p><em>state</em>:</p>
<ulclass="simple">
<li>Can be either ‘installed’, ‘removed’, or ‘latest’. The default is ‘installed’. (In 0.4 and later, the aliases ‘absent’ and ‘present’ can also be used. They correspond with ‘removed’ and ‘installed’)</li>
</ul>
<p><em>update-cache</em>:</p>
<ulclass="simple">
<li>Whether the apt cache must be updated prior to operation. This is equivalent
to doing “apt-get update”. Optional, and can be
‘yes’, or ‘no’. The default is ‘no’. This can be done as the part of a
package operation or as a seperate step.</li>
</ul>
<p><em>purge</em>:</p>
<ulclass="simple">
<li>Will force purge of configuration file for when ensure is set to ‘removed’.
Defaults to ‘no’.</li>
</ul>
<p><em>default-release</em>:</p>
<ulclass="simple">
<li>Corresponds to the -t option for apt, and sets pin priorities</li>
</ul>
<p><em>install-recommends</em>: (devel branch now, part of ansible 0.6 later)</p>
<ulclass="simple">
<li>Corresponds to the –no-install-recommends option for apt. Defaults to ‘yes’, which means install the recommended packages the same way APT does by default. Set this to ‘no’ to add the option not to install recommended packages.</li>
</ul>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="17%"/>
<colwidth="9%"/>
<colwidth="8%"/>
<colwidth="66%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">parameter</th>
<thclass="head">required</th>
<thclass="head">default</th>
<thclass="head">comments</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>name</td>
<td>no</td>
<td> </td>
<td>A package name or package specifier with version, like <cite>foo</cite> or <cite>foo=1.0</cite></td>
</tr>
<tr><td>state</td>
<td>no</td>
<td>present</td>
<td>‘absent’, ‘present’, or ‘latest’.</td>
</tr>
<tr><td>update-cache</td>
<td>no</td>
<td>no</td>
<td>run the equivalent of apt-get update before the operation?
Can be run as part of the package installation or a seperate step</td>
</tr>
<tr><td>purge</td>
<td>no</td>
<td>no</td>
<td>Will forge purge of configuration files if state is set to ‘removed’.</td>
</tr>
<tr><td>default-release</td>
<td>no</td>
<td> </td>
<td>Corresponds to the -t option for apt and sets pin priorities</td>
</tr>
<tr><td>install-recommends</td>
<td>no</td>
<td>yes</td>
<td>Corresponds to the –no-install-recommends option for apt, default
behavior works as apt’s default behavior, ‘no’ does not install
recommended packages. Suggested packages are never installed.</td>
</tr>
</tbody>
</table>
<p>Example action from Ansible <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>:</p>
@ -360,70 +449,129 @@ module behind the scenes.</p>
<h2>fetch<aclass="headerlink"href="#fetch"title="Permalink to this headline">¶</a></h2>
<p>This module works like ‘copy’, but in reverse. It is used for fetching files
from remote machines and storing them locally in a file tree, organized by hostname.</p>
<p><em>src</em>:</p>
<ulclass="simple">
<li>The file on the remote system to fetch. This needs to be a file, not a directory. Recursive fetching may be supported later.</li>
</ul>
<p><em>dest</em>:</p>
<ulclass="simple">
<li>A directory to save the file into. For example, if the ‘dest’ directory is ‘/foo’, a src file named ‘/tmp/bar’ on host ‘host.example.com’, would be saved into ‘/foo/host.example.com/tmp/bar’ (in Ansible 0.0.3 and later).</li>
</ul>
<p>The fetch module is a useful way to gather log files from remote systems. If you require
fetching multiple files from remote systems, you may wish to execute a tar command and
then fetch the tarball.</p>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="17%"/>
<colwidth="9%"/>
<colwidth="8%"/>
<colwidth="66%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">parameter</th>
<thclass="head">required</th>
<thclass="head">default</th>
<thclass="head">comments</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>src</td>
<td>yes</td>
<td> </td>
<td>The file on the remote system to fetch. This needs to be a file, not
a directory. Recursive fetching may be supported in a later release.</td>
</tr>
<tr><td>dest</td>
<td>yes</td>
<td> </td>
<td>A directory to save the file into. For example, if the ‘dest’ directory
is ‘/foo’, a src file named ‘/tmp/bar’ on host ‘host.example.com’, would
be saved into ‘/foo/host.example.com/tmp/bar’</td>
<h2>file<aclass="headerlink"href="#file"title="Permalink to this headline">¶</a></h2>
<p>Sets attributes of files, symlinks, and directories, or removes files/symlinks/directories.
All parameters available to the file module are also available when running the <cite>copy</cite> or
<cite>template</cite> modules.</p>
<p><em>dest</em>:</p>
<ulclass="simple">
<li>alias for ‘path’. Sets an absolute path to a file on the filesystem when used with ‘state=file’. When used with ‘state=link’, sets the destination to create a symbolic link defined by ‘src’ key.</li>
</ul>
<p><em>state</em>:</p>
<ulclass="simple">
<li>either ‘file’, ‘link’, ‘directory’, or ‘absent’. The default is ‘file’. If ‘directory’, the directory and all immediate subdirectories will be created if they do not exist. If ‘file’, the file will NOT be created if it does not exist, specify <cite>copy</cite> or <cite>template</cite> for the module name instead if you need to put content at the specified location. If ‘link’, the symbolic link will be created or changed. If ‘absent’, directories will be recursively deleted, and files or symlinks will be unlinked.</li>
</ul>
<p><em>mode</em>:</p>
<ulclass="simple">
<li>the mode the file or directory should be, such as 644, as would be given to <cite>chmod</cite>. English modes like “g+x” are not yet supported.</li>
</ul>
<p><em>owner</em>:</p>
<ulclass="simple">
<li>name of user that should own the file or directory, as would be given to <cite>chown</cite></li>
</ul>
<p><em>group</em>:</p>
<ulclass="simple">
<li>name of group that should own the file or directory, as would be given to <cite>chgrp</cite></li>
</ul>
<p><em>src</em>:</p>
<ulclass="simple">
<li>path of the file to link to (applies only to ‘link’ state)</li>
</ul>
<p><em>seuser</em>:</p>
<ulclass="simple">
<li>‘user’ part of SELinux file context. Will default to what is provided by system policy, if available. Only used on systems with SELinux present. If you specify ‘_default’, it will use the ‘user’ portion of default context from the policy if available.</li>
</ul>
<p><em>serole</em>:</p>
<ulclass="simple">
<li>‘role’ part of SELinux file context. Will default to what is provided by system policy, if available. Only used on systems with SELinux present. If you specify ‘_default’, it will use the ‘role’ portion of default context from the policy if available.</li>
</ul>
<p><em>setype</em>:</p>
<ulclass="simple">
<li>‘type’ part of SELinux file context. Will default to what is provided by system policy, if available. Only used on systems with SELinux present. If you specify ‘_default’, it will use the ‘type’ portion of default context from the policy if available.</li>
</ul>
<p><em>selevel</em>:</p>
<ulclass="simple">
<li>‘level’ part of SELinux file context. This is the MLS and MCS attribute of the file context, also sometimes known as the ‘range’. It defaults to ‘s0’. Only used only used on hosts with SELinux present. If you specify ‘_default’, it will use the ‘level’ portion of default context from the policy if available.</li>
</ul>
<p><em>context</em>:</p>
<ulclass="simple">
<li>accepts only ‘default’ as value. This will restore a file’s selinux context to the default context in the policy. Does nothing if no default is available. Only used on hosts with SELinux present.</li>
</ul>
<p>Sets attributes of files, symlinks, and directories, or removes files/symlinks/directories. Many other modules
support the same options as the file module – including ‘copy’, ‘template’, and ‘assmeble’.</p>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="17%"/>
<colwidth="9%"/>
<colwidth="8%"/>
<colwidth="66%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">parameter</th>
<thclass="head">required</th>
<thclass="head">default</th>
<thclass="head">comments</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>dest</td>
<td>yes</td>
<td> </td>
<td>defines the file being managed, unless when used with state=link, and
then sets the destination to create a symbolic link to using ‘src’</td>
</tr>
<tr><td>state</td>
<td> </td>
<td>file</td>
<td>values are ‘file’, ‘link’, ‘directory’, or ‘absent’. If directory,
all immediate subdirectories will be created if they do not exist. If
‘file’, the file will NOT be created if it does not exist, see the ‘copy’
or ‘template’ module if you want that behavior. If ‘link’, the symbolic
link will be created or changed. If absent, directories will be
recursively deleted, and files or symlinks will be unlinked.</td>
</tr>
<tr><td>mode</td>
<td> </td>
<td> </td>
<td>mode the file or directory shoudl be, such as 0644 as would be fed to
chmod. English modes like ‘g+x’ are not yet supported</td>
</tr>
<tr><td>owner</td>
<td> </td>
<td> </td>
<td>name of the user that should own the file/directory, as would be fed to
chown</td>
</tr>
<tr><td>group</td>
<td> </td>
<td> </td>
<td>name of the group that should own the file/directory, as would be fed to
group</td>
</tr>
<tr><td>src</td>
<td> </td>
<td> </td>
<td>path of the file to link to (applies only to state=link)</td>
</tr>
<tr><td>seuser</td>
<td> </td>
<td> </td>
<td>user part of SELinux file context. Will default to system policy, if
applicable. If set to ‘_default’, it will use the ‘user’ portion of the
the policy if available</td>
</tr>
<tr><td>serole</td>
<td> </td>
<td> </td>
<td>role part of SELinux file context, ‘_default’ feature works as above.</td>
</tr>
<tr><td>setype</td>
<td> </td>
<td> </td>
<td>type part of SELinux file context, ‘_default’ feature works as above</td>
</tr>
<tr><td>selevel</td>
<td> </td>
<td>s0</td>
<td>level part of the SELinux file context. This is the MLS/MCS attribute,
sometimes known as the ‘range’. ‘_default’ feature works as above</td>
</tr>
<tr><td>context</td>
<td> </td>
<td> </td>
<td>accepts only ‘default’ as a value. This will restore a file’s selinux
context in the policy. Does nothing if no default is available.</td>
</tr>
</tbody>
</table>
<p>Example action from Ansible <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>:</p>
<spanid="id8"></span><h2>group<aclass="headerlink"href="#group"title="Permalink to this headline">¶</a></h2>
<p>Adds or removes groups.</p>
<p><em>name</em>:</p>
<ulclass="simple">
<li>name of the group</li>
</ul>
<p><em>gid</em>:</p>
<ulclass="simple">
<li>optional gid to set for the group</li>
</ul>
<p><em>state</em>:</p>
<ulclass="simple">
<li>either ‘absent’, or ‘present’. ‘present’ is the default.</li>
</ul>
<p><em>system</em>:</p>
<ulclass="simple">
<li>(new in 0.4) Indicates the group (when being created), should be a system group. This does not allow changing groups from and to system groups. Value is ‘yes’ or ‘no’, default is ‘no’.</li>
</ul>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="17%"/>
<colwidth="9%"/>
<colwidth="8%"/>
<colwidth="66%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">parameter</th>
<thclass="head">required</th>
<thclass="head">default</th>
<thclass="head">comments</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>name</td>
<td>yes</td>
<td> </td>
<td>name of the group</td>
</tr>
<tr><td>gid</td>
<td> </td>
<td> </td>
<td>optional git to set for the group</td>
</tr>
<tr><td>state</td>
<td> </td>
<td>present</td>
<td>‘absent’ or ‘present’</td>
</tr>
<tr><td>system</td>
<td> </td>
<td>no</td>
<td>if ‘yes’, indicates that the group being created is a system group.</td>
</tr>
</tbody>
</table>
<p>To control members of the group, see the users resource.</p>
<p>Example action from Ansible <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>:</p>
<h2>service<aclass="headerlink"href="#id11"title="Permalink to this headline">¶</a></h2>
<p>Controls services on remote machines.</p>
<p><em>state</em>:</p>
<ulclass="simple">
<li>Values are <ttclass="docutils literal"><spanclass="pre">started</span></tt>, <ttclass="docutils literal"><spanclass="pre">stopped</span></tt>, <ttclass="docutils literal"><spanclass="pre">reloaded</span></tt>, or <ttclass="docutils literal"><spanclass="pre">restarted</span></tt>.
Started/stopped are idempotent actions that will not run commands
unless necessary. <ttclass="docutils literal"><spanclass="pre">restarted</span></tt> will always bounce the service, <ttclass="docutils literal"><spanclass="pre">reloaded</span></tt>
will always issue a reload.</li>
</ul>
<p><em>enabled</em>:</p>
<ulclass="simple">
<li>(new in 0.4) Whether the service should start on boot. Either ‘yes’ or ‘no’.
Uses chkconfig or updates-rc.d as appropriate.</li>
</ul>
<p><em>list</em>:</p>
<ulclass="simple">
<li>(new in 0.4) When used with the value ‘status’, returns the status of the service along with other results. This is primarily useful for /usr/bin/ansible, and not meaningful for playbooks.</li>
</ul>
<p><em>name</em>:</p>
<ulclass="simple">
<li>The name of the service.</li>
</ul>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="17%"/>
<colwidth="9%"/>
<colwidth="8%"/>
<colwidth="66%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">parameter</th>
<thclass="head">required</th>
<thclass="head">default</th>
<thclass="head">comments</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>name</td>
<td>yes</td>
<td> </td>
<td>name of the service</td>
</tr>
<tr><td>state</td>
<td>no</td>
<td>started</td>
<td>‘started’, ‘stopped’, ‘reloaded’, or ‘restarted’. Started/stopped are
idempotent actions that will not run commands unless neccessary.
‘restarted’ will always bounce the service, ‘reloaded’ will always reload.</td>
</tr>
<tr><td>enabled</td>
<td>no</td>
<td> </td>
<td>Whether the service should start on boot. Either ‘yes’ or ‘no’.</td>
</tr>
<tr><td>list</td>
<td>no</td>
<td> </td>
<td>when used as ‘list=status’, returns the status of the service along with
other results. Primarily useful for /usr/bin/ansible or playbooks with
–verbose.</td>
</tr>
</tbody>
</table>
<p>Example action from Ansible <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>:</p>
@ -547,11 +758,9 @@ service name=httpd state=reloaded</pre>
</div>
<divclass="section"id="setup">
<spanid="id12"></span><h2>setup<aclass="headerlink"href="#setup"title="Permalink to this headline">¶</a></h2>
<p>Writes a JSON file containing key/value data, for use in templating.
Call this once before using the <aclass="reference internal"href="#template"><em>template</em></a> module. Playbooks
will execute this module automatically as the first step in each play
using the variables section, so it is unnecessary to make explicit
calls to setup within a playbook.</p>
<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>
<p>Ansible provides many ‘facts’ about the system, automatically.</p>
<p>Some of the variables that are supplied are listed below. These in particular
are from a VMWare Fusion 4 VM running CentOS 6.2:</p>
@ -625,17 +834,8 @@ tell their source.</p>
<p>All variables are bubbled up to the caller. Using the ansible facts and choosing
to not install facter and ohai means you can avoid ruby-dependencies
on your remote systems.</p>
<p><em>variablename</em>:</p>
<ulclass="simple">
<li>Arbitrary variable names, which must be a mix of alphanumeric characters and underscores, can also be defined. Setting a variable creates a <ttclass="docutils literal"><spanclass="pre">key=value</span></tt> pair in the JSON file for use in templating.</li>
</ul>
<p>Example action from Ansible <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>:</p>
<divclass="highlight-python"><pre>vars:
ntpserver: 'ntp.example.com'
xyz: 1234</pre>
</div>
<p>Example action from <cite>/usr/bin/ansible</cite>:</p>
<divclass="highlight-python"><pre>ansible all -m setup -a "ntpserver=ntp.example.com xyz=1234"</pre>
@ -679,62 +899,96 @@ be a relative or absolute path.</li>
<divclass="section"id="user">
<spanid="id15"></span><h2>user<aclass="headerlink"href="#user"title="Permalink to this headline">¶</a></h2>
<p>Creates user accounts, manipulates existing user accounts, and removes user accounts.</p>
<p><em>name</em>:</p>
<ulclass="simple">
<li>Name of the user to create, remove, or edit</li>
</ul>
<p><em>comment</em>:</p>
<ulclass="simple">
<li>Optionally sets the description of the user</li>
</ul>
<p><em>uid</em>:</p>
<ulclass="simple">
<li>optional uid to set for the user</li>
</ul>
<p><em>group</em>:</p>
<ulclass="simple">
<li>Optionally sets the user’s primary group, takes a group name</li>
</ul>
<p><em>groups</em>:</p>
<ulclass="simple">
<li>Put the user in the specified groups, takes comma delimited group names</li>
</ul>
<p><em>append</em>:</p>
<ulclass="simple">
<li>If true, will only add additional groups to the user listed in ‘groups’, rather than making the user only be in those specified groups</li>
</ul>
<p><em>shell</em>:</p>
<ulclass="simple">
<li>Optionally sets the user’s shell</li>
</ul>
<p><em>createhome</em>:</p>
<ulclass="simple">
<li>Whether to create the user’s home directory. Takes ‘yes’, or ‘no’. The default is ‘yes’.</li>
</ul>
<p><em>home=</em>:</p>
<ulclass="simple">
<li>Specifies where the user’s home directory should be, if not in /home/$username.</li>
</ul>
<p><em>password</em>:</p>
<ulclass="simple">
<li>Sets the user’s password to this crypted value. Pass in a result from crypt. See the users example in the github examples directory for what this looks like in a playbook.</li>
</ul>
<p><em>state</em>:</p>
<ulclass="simple">
<li>Defaults to ‘present’. When ‘absent’, the user account will be removed if present. Optionally additional removal behaviors can be set with the ‘force’ or ‘remove’ parameter values (see below).</li>
</ul>
<p><em>system</em>:</p>
<ulclass="simple">
<li>(new in 0.4) Indicates the user (when being created), should be a system account. This does not allow changing users from and to system accounts. Value is ‘yes’ or ‘no’, default is ‘no’.</li>
</ul>
<p><em>force</em>:</p>
<ulclass="simple">
<li>When used with a state of ‘absent’, the behavior denoted in the ‘userdel’ manpage for <ttclass="docutils literal"><spanclass="pre">--force</span></tt> is also used when removing the user. Value is ‘yes’ or ‘no’, default is ‘no’.</li>
</ul>
<p><em>remove</em>:</p>
<ulclass="simple">
<li>When used with a state of ‘absent’, the behavior denoted in the ‘userdel’ manpage for <ttclass="docutils literal"><spanclass="pre">--remove</span></tt> is also used when removing the user. Value is ‘yes’ or ‘no’, default is ‘no’.</li>
</ul>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="17%"/>
<colwidth="9%"/>
<colwidth="8%"/>
<colwidth="66%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">parameter</th>
<thclass="head">required</th>
<thclass="head">default</th>
<thclass="head">comments</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>name</td>
<td>yes</td>
<td> </td>
<td>name of the user to create, remove, or edit</td>
</tr>
<tr><td>comment</td>
<td> </td>
<td> </td>
<td>optionally sets the description of the user</td>
</tr>
<tr><td>uid</td>
<td> </td>
<td> </td>
<td>optionally sets the uid of the user</td>
</tr>
<tr><td>group</td>
<td> </td>
<td> </td>
<td>optionally sets the user’s primary group (takes a group name)</td>
</tr>
<tr><td>groups</td>
<td> </td>
<td> </td>
<td>puts the user in this comma-delimited list of groups</td>
</tr>
<tr><td>append</td>
<td> </td>
<td>no</td>
<td>if ‘yes’, will only add groups, not set them to just the list in ‘groups’</td>
</tr>
<tr><td>shell</td>
<td> </td>
<td> </td>
<td>optionally set the user’s shell</td>
</tr>
<tr><td>createhome</td>
<td> </td>
<td>yes</td>
<td>unless ‘no’, a home directory will be made for the user</td>
</tr>
<tr><td>home</td>
<td> </td>
<td> </td>
<td>sets where the user’s homedir should be, if not the default</td>
</tr>
<tr><td>password</td>
<td> </td>
<td> </td>
<td>optionally set the user’s password to this crypted value. See the user’s
example in the github examples directory for what this looks like in a
playbook</td>
</tr>
<tr><td>state</td>
<td> </td>
<td>present</td>
<td>when ‘absent’, removes the user.</td>
</tr>
<tr><td>system</td>
<td> </td>
<td>no</td>
<td>only when initially creating, setting this to ‘yes’ makes the user a
system account. This setting cannot be changed on existing users.</td>
</tr>
<tr><td>force</td>
<td> </td>
<td>no</td>
<td>when used with state=absent, behavior is as with userdel –force</td>
</tr>
<tr><td>remove</td>
<td> </td>
<td>no</td>
<td>when used with state=remove, behavior is as with userdel –remove</td>
</tr>
</tbody>
</table>
<p>Example action from Ansible <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>:</p>
@ -745,18 +999,41 @@ user name=mdehaan state=absent force=yes</pre>
<spanid="id16"></span><h2>virt<aclass="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>
<p><em>guest</em>:</p>
<ulclass="simple">
<li>The name of the guest VM being managed</li>
</ul>
<p><em>state</em></p>
<ulclass="simple">
<li>Desired state of the VM. Either <cite>running</cite>, <cite>shutdown</cite>, <cite>destroyed</cite>, or <cite>undefined</cite>. Note that there may be some lag for state requests like ‘shutdown’, and these states only refer to the virtual machine states. After starting a guest, the guest OS may not be immediately accessible.</li>
</ul>
<p><em>command</em>:</p>
<ulclass="simple">
<li>In addition to state management, various non-idempotent commands are available for API and script usage (but don’t make much sense in a playbook). These mostly return information, though some also affect state. See examples below.</li>
</ul>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="17%"/>
<colwidth="9%"/>
<colwidth="8%"/>
<colwidth="66%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">parameter</th>
<thclass="head">required</th>
<thclass="head">default</th>
<thclass="head">comments</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>name</td>
<td>yes</td>
<td> </td>
<td>name of the guest VM being managed</td>
</tr>
<tr><td>state</td>
<td> </td>
<td> </td>
<td>‘running’, ‘shutdown’, ‘destroyed’, or ‘undefined’. Note that there may
be some lag for state requests like ‘shutdown’ since these refer only to
VM states. After starting a guest, it may not be immediately accessible.</td>
</tr>
<tr><td>command</td>
<td> </td>
<td> </td>
<td>in addition to state management, various non-idempotent commands are
available. See examples below.</td>
</tr>
</tbody>
</table>
<p>Example action from Ansible <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>:</p>
@ -781,21 +1058,39 @@ ansible host -m virt -a "command=virttype"</pre>
<divclass="section"id="yum">
<spanid="id17"></span><h2>yum<aclass="headerlink"href="#yum"title="Permalink to this headline">¶</a></h2>
<p>Will install, upgrade, remove, and list packages with the yum package manager.</p>
<p><em>pkg</em>:</p>
<ulclass="simple">
<li>A package name or package specifier with version, like name-1.0</li>
</ul>
<p><em>state</em>:</p>
<ulclass="simple">
<li>Can be either ‘installed’, ‘latest’, or ‘removed’. The default is ‘installed’. (In 0.4 and later, the aliases ‘absent’ and ‘present’ can also be used. They correspond with ‘removed’ and ‘installed’)</li>
</ul>
<p><em>list</em>:</p>
<ulclass="simple">
<li>When ‘list’ is supplied instead of ‘state’, the yum module can list
various configuration attributes. Values include ‘installed’, ‘updates’,
‘available’, ‘repos’, or any package specifier. (This is more intended for
use with /usr/bin/ansible or the API, not playbooks.)</li>
</ul>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="17%"/>
<colwidth="9%"/>
<colwidth="8%"/>
<colwidth="66%"/>
</colgroup>
<theadvalign="bottom">
<tr><thclass="head">parameter</th>
<thclass="head">required</th>
<thclass="head">default</th>
<thclass="head">comments</th>
</tr>
</thead>
<tbodyvalign="top">
<tr><td>name</td>
<td>yes</td>
<td> </td>
<td>package name, or package specifier with version, like ‘name-1.0’</td>
</tr>
<tr><td>state</td>
<td> </td>
<td>present</td>
<td>‘present’, ‘latest’, or ‘absent’.</td>
</tr>
<tr><td>list</td>
<td> </td>
<td> </td>
<td>various non-idempotent commands for usage with /usr/bin/ansible and not
playbooks. See examples below.</td>
</tr>
</tbody>
</table>
<p>Example action from Ansible <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>:</p>
@ -14,9 +14,8 @@ Let's review how we execute three different modules from the command line::
ansible webservers -m command -a "/sbin/reboot -t now"
Each module supports taking arguments. Nearly all modules take ``key=value``
arguments, space delimited. Some modules take
no arguments, and the command/shell modules simply take the string
of the command you want to run.
arguments, space delimited. Some modules take no arguments, and the
command/shell modules simply take the string of the command you want to run.
From playbooks, Ansible modules are executed in a very similar way::
@ -42,33 +41,24 @@ apt
Manages apt-packages (such as for Debian/Ubuntu).
*pkg*:
* A package name or package specifier with version, like `foo`, or `foo=1.0` to install a specific version of the foo package.
*state*:
* Can be either 'installed', 'removed', or 'latest'. The default is 'installed'. (In 0.4 and later, the aliases 'absent' and 'present' can also be used. They correspond with 'removed' and 'installed')
*update-cache*:
* Whether the apt cache must be updated prior to operation. This is equivalent
to doing "apt-get update". Optional, and can be
'yes', or 'no'. The default is 'no'. This can be done as the part of a
package operation or as a seperate step.
*purge*:
* Will force purge of configuration file for when ensure is set to 'removed'.
Defaults to 'no'.
*default-release*:
* Corresponds to the -t option for apt, and sets pin priorities
*install-recommends*: (devel branch now, part of ansible 0.6 later)
* Corresponds to the --no-install-recommends option for apt. Defaults to 'yes', which means install the recommended packages the same way APT does by default. Set this to 'no' to add the option not to install recommended packages.
This module also returns md5sum information about the resultant file.
This module also returns md5sum and other information about the resultant file.
Example action from Ansible :doc:`playbooks`::
@ -208,17 +199,16 @@ fetch
This module works like 'copy', but in reverse. It is used for fetching files
from remote machines and storing them locally in a file tree, organized by hostname.
*src*:
* The file on the remote system to fetch. This needs to be a file, not a directory. Recursive fetching may be supported later.
*dest*:
* A directory to save the file into. For example, if the 'dest' directory is '/foo', a src file named '/tmp/bar' on host 'host.example.com', would be saved into '/foo/host.example.com/tmp/bar' (in Ansible 0.0.3 and later).
The fetch module is a useful way to gather log files from remote systems. If you require
fetching multiple files from remote systems, you may wish to execute a tar command and
Sets attributes of files, symlinks, and directories, or removes files/symlinks/directories.
All parameters available to the file module are also available when running the `copy` or
`template` modules.
*dest*:
* alias for 'path'. Sets an absolute path to a file on the filesystem when used with 'state=file'. When used with 'state=link', sets the destination to create a symbolic link defined by 'src' key.
*state*:
* either 'file', 'link', 'directory', or 'absent'. The default is 'file'. If 'directory', the directory and all immediate subdirectories will be created if they do not exist. If 'file', the file will NOT be created if it does not exist, specify `copy` or `template` for the module name instead if you need to put content at the specified location. If 'link', the symbolic link will be created or changed. If 'absent', directories will be recursively deleted, and files or symlinks will be unlinked.
*mode*:
* the mode the file or directory should be, such as 644, as would be given to `chmod`. English modes like "g+x" are not yet supported.
*owner*:
* name of user that should own the file or directory, as would be given to `chown`
*group*:
* name of group that should own the file or directory, as would be given to `chgrp`
*src*:
* path of the file to link to (applies only to 'link' state)
*seuser*:
* 'user' part of SELinux file context. Will default to what is provided by system policy, if available. Only used on systems with SELinux present. If you specify '_default', it will use the 'user' portion of default context from the policy if available.
*serole*:
* 'role' part of SELinux file context. Will default to what is provided by system policy, if available. Only used on systems with SELinux present. If you specify '_default', it will use the 'role' portion of default context from the policy if available.
*setype*:
* 'type' part of SELinux file context. Will default to what is provided by system policy, if available. Only used on systems with SELinux present. If you specify '_default', it will use the 'type' portion of default context from the policy if available.
*selevel*:
* 'level' part of SELinux file context. This is the MLS and MCS attribute of the file context, also sometimes known as the 'range'. It defaults to 's0'. Only used only used on hosts with SELinux present. If you specify '_default', it will use the 'level' portion of default context from the policy if available.
*context*:
* accepts only 'default' as value. This will restore a file's selinux context to the default context in the policy. Does nothing if no default is available. Only used on hosts with SELinux present.
Sets attributes of files, symlinks, and directories, or removes files/symlinks/directories. Many other modules
support the same options as the file module -- including 'copy', 'template', and 'assmeble'.
* either 'absent', or 'present'. 'present' is the default.
*system*:
* (new in 0.4) Indicates the group (when being created), should be a system group. This does not allow changing groups from and to system groups. Value is 'yes' or 'no', default is 'no'.
To control members of the group, see the users resource.
@ -398,25 +373,21 @@ service
Controls services on remote machines.
*state*:
* Values are ``started``, ``stopped``, ``reloaded``, or ``restarted``.
Started/stopped are idempotent actions that will not run commands
unless necessary. ``restarted`` will always bounce the service, ``reloaded``
will always issue a reload.
*enabled*:
* (new in 0.4) Whether the service should start on boot. Either 'yes' or 'no'.
Uses chkconfig or updates-rc.d as appropriate.
*list*:
* (new in 0.4) When used with the value 'status', returns the status of the service along with other results. This is primarily useful for /usr/bin/ansible, and not meaningful for playbooks.
@ -430,11 +401,9 @@ Example action from Ansible :doc:`playbooks`::
setup
`````
Writes a JSON file containing key/value data, for use in templating.
Call this once before using the :ref:`template` module. Playbooks
will execute this module automatically as the first step in each play
using the variables section, so it is unnecessary to make explicit
calls to setup within a playbook.
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.
Ansible provides many 'facts' about the system, automatically.
@ -514,19 +483,9 @@ All variables are bubbled up to the caller. Using the ansible facts and choosin
to not install facter and ohai means you can avoid ruby-dependencies
on your remote systems.
*variablename*:
* Arbitrary variable names, which must be a mix of alphanumeric characters and underscores, can also be defined. Setting a variable creates a ``key=value`` pair in the JSON file for use in templating.
Example action from Ansible :doc:`playbooks`::
vars:
ntpserver: 'ntp.example.com'
xyz: 1234
Example action from `/usr/bin/ansible`::
ansible all -m setup -a "ntpserver=ntp.example.com xyz=1234"
ansible testserver -m setup
.._shell:
@ -560,21 +519,18 @@ Example action from a playbook::
template
````````
Templates a file out to a remote server. Call the :ref:`setup` module
prior to usage if you are not running from a playbook. In addition to the options
listed below, the arguments available to the `file` and `copy` modules can also be passed
to the template module.
*src*:
* Path of a Jinja2 formatted template on the local server. This can
be a relative or absolute path.
Templates a file out to a remote server.
*dest*:
* Location to render the template on the remote server
This module also returns md5sum information about the resultant file.
Creates user accounts, manipulates existing user accounts, and removes user accounts.
*name*:
* Name of the user to create, remove, or edit
*comment*:
* Optionally sets the description of the user
*uid*:
* optional uid to set for the user
*group*:
* Optionally sets the user's primary group, takes a group name
*groups*:
* Put the user in the specified groups, takes comma delimited group names
*append*:
* If true, will only add additional groups to the user listed in 'groups', rather than making the user only be in those specified groups
*shell*:
* Optionally sets the user's shell
*createhome*:
* Whether to create the user's home directory. Takes 'yes', or 'no'. The default is 'yes'.
*home=*:
* Specifies where the user's home directory should be, if not in /home/$username.
*password*:
* Sets the user's password to this crypted value. Pass in a result from crypt. See the users example in the github examples directory for what this looks like in a playbook.
*state*:
* Defaults to 'present'. When 'absent', the user account will be removed if present. Optionally additional removal behaviors can be set with the 'force' or 'remove' parameter values (see below).
*system*:
* (new in 0.4) Indicates the user (when being created), should be a system account. This does not allow changing users from and to system accounts. Value is 'yes' or 'no', default is 'no'.
*force*:
* When used with a state of 'absent', the behavior denoted in the 'userdel' manpage for ``--force`` is also used when removing the user. Value is 'yes' or 'no', default is 'no'.
*remove*:
* When used with a state of 'absent', the behavior denoted in the 'userdel' manpage for ``--remove`` is also used when removing the user. Value is 'yes' or 'no', default is 'no'.
Manages virtual machines supported by libvirt. Requires that libvirt be installed
on the managed machine.
*guest*:
* The name of the guest VM being managed
*state*
* Desired state of the VM. Either `running`, `shutdown`, `destroyed`, or `undefined`. Note that there may be some lag for state requests like 'shutdown', and these states only refer to the virtual machine states. After starting a guest, the guest OS may not be immediately accessible.
*command*:
* In addition to state management, various non-idempotent commands are available for API and script usage (but don't make much sense in a playbook). These mostly return information, though some also affect state. See examples below.
Will install, upgrade, remove, and list packages with the yum package manager.
*pkg*:
* A package name or package specifier with version, like name-1.0
*state*:
* Can be either 'installed', 'latest', or 'removed'. The default is 'installed'. (In 0.4 and later, the aliases 'absent' and 'present' can also be used. They correspond with 'removed' and 'installed')
*list*:
* When 'list' is supplied instead of 'state', the yum module can list
various configuration attributes. Values include 'installed', 'updates',
'available', 'repos', or any package specifier. (This is more intended for
use with /usr/bin/ansible or the API, not playbooks.)