ansible webservers -m command -a "/sbin/reboot -t now"</pre>
ansible webservers -m command -a "/sbin/reboot -t now"</pre>
</div>
</div>
<p>Each module supports taking arguments. Nearly all modules take <ttclass="docutils literal"><spanclass="pre">key=value</span></tt>
<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
arguments, space delimited. Some modules take no arguments, and the
no arguments, and the command/shell modules simply take the string
command/shell modules simply take the string of the command you want to run.</p>
of the command you want to run.</p>
<p>From playbooks, Ansible modules are executed in a very similar way:</p>
<p>From playbooks, Ansible modules are executed in a very similar way:</p>
<divclass="highlight-python"><pre>- name: reboot the servers
<divclass="highlight-python"><pre>- name: reboot the servers
action: command /sbin/reboot -t now</pre>
action: command /sbin/reboot -t now</pre>
@ -229,34 +228,56 @@ noted, any given module does support change hooks.</p>
<divclass="section"id="apt">
<divclass="section"id="apt">
<spanid="id1"></span><h2>apt<aclass="headerlink"href="#apt"title="Permalink to this headline">¶</a></h2>
<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>Manages apt-packages (such as for Debian/Ubuntu).</p>
<p><em>pkg</em>:</p>
<tableborder="1"class="docutils">
<ulclass="simple">
<colgroup>
<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>
<colwidth="17%"/>
</ul>
<colwidth="9%"/>
<p><em>state</em>:</p>
<colwidth="8%"/>
<ulclass="simple">
<colwidth="66%"/>
<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>
</colgroup>
</ul>
<theadvalign="bottom">
<p><em>update-cache</em>:</p>
<tr><thclass="head">parameter</th>
<ulclass="simple">
<thclass="head">required</th>
<li>Whether the apt cache must be updated prior to operation. This is equivalent
<thclass="head">default</th>
to doing “apt-get update”. Optional, and can be
<thclass="head">comments</th>
‘yes’, or ‘no’. The default is ‘no’. This can be done as the part of a
</tr>
package operation or as a seperate step.</li>
</thead>
</ul>
<tbodyvalign="top">
<p><em>purge</em>:</p>
<tr><td>name</td>
<ulclass="simple">
<td>no</td>
<li>Will force purge of configuration file for when ensure is set to ‘removed’.
<td> </td>
Defaults to ‘no’.</li>
<td>A package name or package specifier with version, like <cite>foo</cite> or <cite>foo=1.0</cite></td>
</ul>
</tr>
<p><em>default-release</em>:</p>
<tr><td>state</td>
<ulclass="simple">
<td>no</td>
<li>Corresponds to the -t option for apt, and sets pin priorities</li>
<td>present</td>
</ul>
<td>‘absent’, ‘present’, or ‘latest’.</td>
<p><em>install-recommends</em>: (devel branch now, part of ansible 0.6 later)</p>
</tr>
<ulclass="simple">
<tr><td>update-cache</td>
<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>
<td>no</td>
</ul>
<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>
<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>
<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
<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>
from remote machines and storing them locally in a file tree, organized by hostname.</p>
<p><em>src</em>:</p>
<tableborder="1"class="docutils">
<ulclass="simple">
<colgroup>
<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>
<colwidth="17%"/>
</ul>
<colwidth="9%"/>
<p><em>dest</em>:</p>
<colwidth="8%"/>
<ulclass="simple">
<colwidth="66%"/>
<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>
</colgroup>
</ul>
<theadvalign="bottom">
<p>The fetch module is a useful way to gather log files from remote systems. If you require
<tr><thclass="head">parameter</th>
fetching multiple files from remote systems, you may wish to execute a tar command and
<thclass="head">required</th>
then fetch the tarball.</p>
<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>
<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.
<p>Sets attributes of files, symlinks, and directories, or removes files/symlinks/directories. Many other modules
All parameters available to the file module are also available when running the <cite>copy</cite> or
support the same options as the file module – including ‘copy’, ‘template’, and ‘assmeble’.</p>
<cite>template</cite> modules.</p>
<tableborder="1"class="docutils">
<p><em>dest</em>:</p>
<colgroup>
<ulclass="simple">
<colwidth="17%"/>
<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>
<colwidth="9%"/>
</ul>
<colwidth="8%"/>
<p><em>state</em>:</p>
<colwidth="66%"/>
<ulclass="simple">
</colgroup>
<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>
<theadvalign="bottom">
</ul>
<tr><thclass="head">parameter</th>
<p><em>mode</em>:</p>
<thclass="head">required</th>
<ulclass="simple">
<thclass="head">default</th>
<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>
<thclass="head">comments</th>
</ul>
</tr>
<p><em>owner</em>:</p>
</thead>
<ulclass="simple">
<tbodyvalign="top">
<li>name of user that should own the file or directory, as would be given to <cite>chown</cite></li>
<tr><td>dest</td>
</ul>
<td>yes</td>
<p><em>group</em>:</p>
<td> </td>
<ulclass="simple">
<td>defines the file being managed, unless when used with state=link, and
<li>name of group that should own the file or directory, as would be given to <cite>chgrp</cite></li>
then sets the destination to create a symbolic link to using ‘src’</td>
</ul>
</tr>
<p><em>src</em>:</p>
<tr><td>state</td>
<ulclass="simple">
<td> </td>
<li>path of the file to link to (applies only to ‘link’ state)</li>
<td>file</td>
</ul>
<td>values are ‘file’, ‘link’, ‘directory’, or ‘absent’. If directory,
<p><em>seuser</em>:</p>
all immediate subdirectories will be created if they do not exist. If
<ulclass="simple">
‘file’, the file will NOT be created if it does not exist, see the ‘copy’
<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>
or ‘template’ module if you want that behavior. If ‘link’, the symbolic
</ul>
link will be created or changed. If absent, directories will be
<p><em>serole</em>:</p>
recursively deleted, and files or symlinks will be unlinked.</td>
<ulclass="simple">
</tr>
<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>
<tr><td>mode</td>
</ul>
<td> </td>
<p><em>setype</em>:</p>
<td> </td>
<ulclass="simple">
<td>mode the file or directory shoudl be, such as 0644 as would be fed to
<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>
chmod. English modes like ‘g+x’ are not yet supported</td>
</ul>
</tr>
<p><em>selevel</em>:</p>
<tr><td>owner</td>
<ulclass="simple">
<td> </td>
<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>
<td> </td>
</ul>
<td>name of the user that should own the file/directory, as would be fed to
<p><em>context</em>:</p>
chown</td>
<ulclass="simple">
</tr>
<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>
<tr><td>group</td>
</ul>
<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>
<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>
<spanid="id8"></span><h2>group<aclass="headerlink"href="#group"title="Permalink to this headline">¶</a></h2>
<p>Adds or removes groups.</p>
<p>Adds or removes groups.</p>
<p><em>name</em>:</p>
<tableborder="1"class="docutils">
<ulclass="simple">
<colgroup>
<li>name of the group</li>
<colwidth="17%"/>
</ul>
<colwidth="9%"/>
<p><em>gid</em>:</p>
<colwidth="8%"/>
<ulclass="simple">
<colwidth="66%"/>
<li>optional gid to set for the group</li>
</colgroup>
</ul>
<theadvalign="bottom">
<p><em>state</em>:</p>
<tr><thclass="head">parameter</th>
<ulclass="simple">
<thclass="head">required</th>
<li>either ‘absent’, or ‘present’. ‘present’ is the default.</li>
<thclass="head">default</th>
</ul>
<thclass="head">comments</th>
<p><em>system</em>:</p>
</tr>
<ulclass="simple">
</thead>
<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>
<tbodyvalign="top">
</ul>
<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>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>
<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>
<h2>service<aclass="headerlink"href="#id11"title="Permalink to this headline">¶</a></h2>
<p>Controls services on remote machines.</p>
<p>Controls services on remote machines.</p>
<p><em>state</em>:</p>
<tableborder="1"class="docutils">
<ulclass="simple">
<colgroup>
<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>.
<colwidth="17%"/>
Started/stopped are idempotent actions that will not run commands
<colwidth="9%"/>
unless necessary. <ttclass="docutils literal"><spanclass="pre">restarted</span></tt> will always bounce the service, <ttclass="docutils literal"><spanclass="pre">reloaded</span></tt>
<colwidth="8%"/>
will always issue a reload.</li>
<colwidth="66%"/>
</ul>
</colgroup>
<p><em>enabled</em>:</p>
<theadvalign="bottom">
<ulclass="simple">
<tr><thclass="head">parameter</th>
<li>(new in 0.4) Whether the service should start on boot. Either ‘yes’ or ‘no’.
<thclass="head">required</th>
Uses chkconfig or updates-rc.d as appropriate.</li>
<thclass="head">default</th>
</ul>
<thclass="head">comments</th>
<p><em>list</em>:</p>
</tr>
<ulclass="simple">
</thead>
<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>
<tbodyvalign="top">
</ul>
<tr><td>name</td>
<p><em>name</em>:</p>
<td>yes</td>
<ulclass="simple">
<td> </td>
<li>The name of the service.</li>
<td>name of the service</td>
</ul>
</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>
<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>
</div>
<divclass="section"id="setup">
<divclass="section"id="setup">
<spanid="id12"></span><h2>setup<aclass="headerlink"href="#setup"title="Permalink to this headline">¶</a></h2>
<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.
<p>This module is automatically called by playbooks to gather useful variables about remote hosts that can be used
Call this once before using the <aclass="reference internal"href="#template"><em>template</em></a> module. Playbooks
in playbooks. It can also be executed directly by /usr/bin/ansible to check what variables are available
will execute this module automatically as the first step in each play
to a host.</p>
using the variables section, so it is unnecessary to make explicit
calls to setup within a playbook.</p>
<p>Ansible provides many ‘facts’ about the system, automatically.</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
<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>
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
<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
to not install facter and ohai means you can avoid ruby-dependencies
on your remote systems.</p>
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>
<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">
<divclass="section"id="user">
<spanid="id15"></span><h2>user<aclass="headerlink"href="#user"title="Permalink to this headline">¶</a></h2>
<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>Creates user accounts, manipulates existing user accounts, and removes user accounts.</p>
<p><em>name</em>:</p>
<tableborder="1"class="docutils">
<ulclass="simple">
<colgroup>
<li>Name of the user to create, remove, or edit</li>
<colwidth="17%"/>
</ul>
<colwidth="9%"/>
<p><em>comment</em>:</p>
<colwidth="8%"/>
<ulclass="simple">
<colwidth="66%"/>
<li>Optionally sets the description of the user</li>
</colgroup>
</ul>
<theadvalign="bottom">
<p><em>uid</em>:</p>
<tr><thclass="head">parameter</th>
<ulclass="simple">
<thclass="head">required</th>
<li>optional uid to set for the user</li>
<thclass="head">default</th>
</ul>
<thclass="head">comments</th>
<p><em>group</em>:</p>
</tr>
<ulclass="simple">
</thead>
<li>Optionally sets the user’s primary group, takes a group name</li>
<tbodyvalign="top">
</ul>
<tr><td>name</td>
<p><em>groups</em>:</p>
<td>yes</td>
<ulclass="simple">
<td> </td>
<li>Put the user in the specified groups, takes comma delimited group names</li>
<td>name of the user to create, remove, or edit</td>
</ul>
</tr>
<p><em>append</em>:</p>
<tr><td>comment</td>
<ulclass="simple">
<td> </td>
<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>
<td> </td>
</ul>
<td>optionally sets the description of the user</td>
<p><em>shell</em>:</p>
</tr>
<ulclass="simple">
<tr><td>uid</td>
<li>Optionally sets the user’s shell</li>
<td> </td>
</ul>
<td> </td>
<p><em>createhome</em>:</p>
<td>optionally sets the uid of the user</td>
<ulclass="simple">
</tr>
<li>Whether to create the user’s home directory. Takes ‘yes’, or ‘no’. The default is ‘yes’.</li>
<tr><td>group</td>
</ul>
<td> </td>
<p><em>home=</em>:</p>
<td> </td>
<ulclass="simple">
<td>optionally sets the user’s primary group (takes a group name)</td>
<li>Specifies where the user’s home directory should be, if not in /home/$username.</li>
</tr>
</ul>
<tr><td>groups</td>
<p><em>password</em>:</p>
<td> </td>
<ulclass="simple">
<td> </td>
<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>
<td>puts the user in this comma-delimited list of groups</td>
</ul>
</tr>
<p><em>state</em>:</p>
<tr><td>append</td>
<ulclass="simple">
<td> </td>
<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>
<td>no</td>
</ul>
<td>if ‘yes’, will only add groups, not set them to just the list in ‘groups’</td>
<p><em>system</em>:</p>
</tr>
<ulclass="simple">
<tr><td>shell</td>
<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>
<td> </td>
</ul>
<td> </td>
<p><em>force</em>:</p>
<td>optionally set the user’s shell</td>
<ulclass="simple">
</tr>
<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>
<tr><td>createhome</td>
</ul>
<td> </td>
<p><em>remove</em>:</p>
<td>yes</td>
<ulclass="simple">
<td>unless ‘no’, a home directory will be made for the user</td>
<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>
</tr>
</ul>
<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>
<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>
<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
<p>Manages virtual machines supported by libvirt. Requires that libvirt be installed
on the managed machine.</p>
on the managed machine.</p>
<p><em>guest</em>:</p>
<tableborder="1"class="docutils">
<ulclass="simple">
<colgroup>
<li>The name of the guest VM being managed</li>
<colwidth="17%"/>
</ul>
<colwidth="9%"/>
<p><em>state</em></p>
<colwidth="8%"/>
<ulclass="simple">
<colwidth="66%"/>
<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>
</colgroup>
</ul>
<theadvalign="bottom">
<p><em>command</em>:</p>
<tr><thclass="head">parameter</th>
<ulclass="simple">
<thclass="head">required</th>
<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>
<thclass="head">default</th>
</ul>
<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>
<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">
<divclass="section"id="yum">
<spanid="id17"></span><h2>yum<aclass="headerlink"href="#yum"title="Permalink to this headline">¶</a></h2>
<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>Will install, upgrade, remove, and list packages with the yum package manager.</p>
<p><em>pkg</em>:</p>
<tableborder="1"class="docutils">
<ulclass="simple">
<colgroup>
<li>A package name or package specifier with version, like name-1.0</li>
<colwidth="17%"/>
</ul>
<colwidth="9%"/>
<p><em>state</em>:</p>
<colwidth="8%"/>
<ulclass="simple">
<colwidth="66%"/>
<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>
</colgroup>
</ul>
<theadvalign="bottom">
<p><em>list</em>:</p>
<tr><thclass="head">parameter</th>
<ulclass="simple">
<thclass="head">required</th>
<li>When ‘list’ is supplied instead of ‘state’, the yum module can list
<thclass="head">default</th>
various configuration attributes. Values include ‘installed’, ‘updates’,
<thclass="head">comments</th>
‘available’, ‘repos’, or any package specifier. (This is more intended for
</tr>
use with /usr/bin/ansible or the API, not playbooks.)</li>
</thead>
</ul>
<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>
<p>Example action from Ansible <aclass="reference internal"href="playbooks.html"><em>Playbooks</em></a>:</p>
| state | no | present | 'absent', 'present', or 'latest'. |
* 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')
* 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.
Example action from Ansible :doc:`playbooks`::
Example action from Ansible :doc:`playbooks`::
@ -90,13 +80,15 @@ Assmeble will take a directory of files that have already been transferred to th
together to produce a destination file. Files are assembled in string sorting order. Puppet calls this idea
together to produce a destination file. Files are assembled in string sorting order. Puppet calls this idea
* 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).
| dest | yes | | 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 |
The fetch module is a useful way to gather log files from remote systems. If you require
| | | | be saved into '/foo/host.example.com/tmp/bar' |
fetching multiple files from remote systems, you may wish to execute a tar command and
* 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.
| dest | yes | | defines the file being managed, unless when used with state=link, and |
| | | | then sets the destination to create a symbolic link to using 'src' |
| state | | file | values are 'file', 'link', 'directory', or 'absent'. If directory, |
* 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.
| | | | 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' |
*mode*:
| | | | or 'template' module if you want that behavior. If 'link', the symbolic |
| | | | link will be created or changed. If absent, directories will be |
* 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.
| | | | recursively deleted, and files or symlinks will be unlinked. |
| seuser | | | user part of SELinux file context. Will default to system policy, if |
*seuser*:
| | | | applicable. If set to '_default', it will use the 'user' portion of the |
| | | | the policy if available |
* '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.
| setype | | | type part of SELinux file context, '_default' feature works as above |
* '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.
* '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.
| context | | | accepts only 'default' as a value. This will restore a file's selinux |
| | | | context in the policy. Does nothing if no default is available. |
* '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.
* (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.
To control members of the group, see the users resource.
| list | no | | when used as 'list=status', returns the status of the service along with |
*list*:
| | | | other results. Primarily useful for /usr/bin/ansible or playbooks with |
| | | | --verbose. |
* (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
setup
`````
`````
Writes a JSON file containing key/value data, for use in templating.
This module is automatically called by playbooks to gather useful variables about remote hosts that can be used
Call this once before using the :ref:`template` module. Playbooks
in playbooks. It can also be executed directly by /usr/bin/ansible to check what variables are available
will execute this module automatically as the first step in each play
to a host.
using the variables section, so it is unnecessary to make explicit
calls to setup within a playbook.
Ansible provides many 'facts' about the system, automatically.
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
to not install facter and ohai means you can avoid ruby-dependencies
on your remote systems.
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`::
Example action from `/usr/bin/ansible`::
ansible all -m setup -a "ntpserver=ntp.example.com xyz=1234"
ansible testserver -m setup
.._shell:
.._shell:
@ -560,21 +519,18 @@ Example action from a playbook::
template
template
````````
````````
Templates a file out to a remote server. Call the :ref:`setup` module
Templates a file out to a remote server.
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
* 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'.
Example action from Ansible :doc:`playbooks`::
Example action from Ansible :doc:`playbooks`::
@ -658,17 +593,18 @@ virt
Manages virtual machines supported by libvirt. Requires that libvirt be installed
Manages virtual machines supported by libvirt. Requires that libvirt be installed
| state | | | 'running', 'shutdown', 'destroyed', or 'undefined'. Note that there may |
* 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.
| | | | 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. |
| command | | | in addition to state management, various non-idempotent commands are |
* 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.
| state | | present | 'present', 'latest', or 'absent'. |
* 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')