ansible/html/patterns.html

219 lines
8.7 KiB
HTML
Raw Normal View History

2012-03-07 17:35:18 +01:00
<!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" />
2012-03-08 19:53:48 +01:00
<title>The Inventory File, Patterns, and Groups &mdash; Ansible v0.0.1 documentation</title>
2012-03-07 17:35:18 +01:00
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
2012-03-07 17:35:18 +01:00
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
2012-03-09 17:50:07 +01:00
HAS_SOURCE: false
2012-03-07 17:35:18 +01:00
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/bootstrap-dropdown.js"></script>
<script type="text/javascript" src="_static/bootstrap-scrollspy.js"></script>
2012-03-07 17:35:18 +01:00
<link rel="top" title="Ansible v0.0.1 documentation" href="index.html" />
2012-03-09 13:42:53 +01:00
<link rel="next" title="Command Line Examples" href="examples.html" />
<link rel="prev" title="Getting Started" href="gettingstarted.html" />
<script type="text/javascript">
(function () {
/**
* Patch TOC list.
*
* Will mutate the underlying span to have a correct ul for nav.
*
* @param $span: Span containing nested UL's to mutate.
* @param minLevel: Starting level for nested lists. (1: global, 2: local).
*/
var patchToc = function ($span, minLevel) {
var $tocList = $("<ul/>").attr('class', "dropdown-menu"),
findA;
// Find all a "internal" tags, traversing recursively.
findA = function ($elem, level) {
var level = level || 0,
$items = $elem.find("> li > a.internal, > ul, > li > ul");
// Iterate everything in order.
$items.each(function (index, item) {
var $item = $(item),
tag = item.tagName.toLowerCase(),
pad = 10 + ((level - minLevel) * 10);
if (tag === 'a' && level >= minLevel) {
// Add to existing padding.
$item.css('padding-left', pad + "px");
// Add list element.
$tocList.append($("<li/>").append($item));
} else if (tag === 'ul') {
// Recurse.
findA($item, level + 1);
}
});
};
// Start construction and return.
findA($span);
// Wipe out old list and patch in new one.
return $span.empty("ul").append($tocList);
};
$(document).ready(function () {
// Patch the global and local TOC's to be bootstrap-compliant.
patchToc($("span.globaltoc"), 1);
patchToc($("span.localtoc"), 2);
// Activate.
$('#topbar').dropdown();
});
}());
</script>
2012-03-07 17:35:18 +01:00
</head>
<body>
<div class="topbar" data-scrollspy="scrollspy" >
<div class="topbar-inner">
<div class="container">
<a class="brand" href="index.html">Ansible</a>
<ul class="nav">
<li class="dropdown" data-dropdown="dropdown">
<a href="index.html"
class="dropdown-toggle">Site</a>
<span class="globaltoc"><ul class="current">
<li class="toctree-l1"><a class="reference internal" href="gettingstarted.html">Getting Started</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">The Inventory File, Patterns, and Groups</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Command Line Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="modules.html">Ansible Modules</a></li>
<li class="toctree-l1"><a class="reference internal" href="YAMLScripts.html">YAML Format</a></li>
<li class="toctree-l1"><a class="reference internal" href="playbooks.html">Playbooks</a></li>
<li class="toctree-l1"><a class="reference internal" href="api.html">Using the Python API</a></li>
<li class="toctree-l1"><a class="reference internal" href="man.html">Man Pages</a></li>
</ul>
</span>
</li>
<li class="dropdown" data-dropdown="dropdown">
<a href="#"
class="dropdown-toggle">Page</a>
<span class="localtoc"><ul>
<li><a class="reference internal" href="#">The Inventory File, Patterns, and Groups</a><ul>
<li><a class="reference internal" href="#inventory-file-format">Inventory File Format</a></li>
<li><a class="reference internal" href="#selecting-targets">Selecting Targets</a></li>
</ul>
</li>
</ul>
</span>
</li>
<li><a href="gettingstarted.html"
title="previous chapter">&laquo; Getting Started</a></li>
<li><a href="examples.html"
title="next chapter">Command Line Examples &raquo;</a></li>
2012-03-07 17:35:18 +01:00
</ul>
<ul class="nav secondary-nav">
<form class="pull-left" action="search.html" method="get">
<input type="text" name="q" placeholder="Search" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</ul>
</div>
</div>
</div>
<div class="container">
2012-03-08 19:53:48 +01:00
<div class="section" id="the-inventory-file-patterns-and-groups">
<span id="patterns"></span><h1>The Inventory File, Patterns, and Groups<a class="headerlink" href="#the-inventory-file-patterns-and-groups" title="Permalink to this headline"></a></h1>
2012-03-08 19:36:47 +01:00
<p>How to select hosts you wish to manage</p>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
2012-03-09 13:42:53 +01:00
<dt><a class="reference internal" href="examples.html"><em>Command Line Examples</em></a></dt>
2012-03-08 19:36:47 +01:00
<dd>Examples of basic commands</dd>
<dt><a class="reference internal" href="playbooks.html"><em>Playbooks</em></a></dt>
2012-03-08 19:36:47 +01:00
<dd>Learning ansible&#8217;s configuration management language</dd>
</dl>
</div>
2012-03-08 19:53:48 +01:00
<div class="section" id="inventory-file-format">
<h2>Inventory File Format<a class="headerlink" href="#inventory-file-format" title="Permalink to this headline"></a></h2>
2012-03-08 19:36:47 +01:00
<p>Ansible works against multiple systems in your infrastructure at the
same time. It does this by selecting portions of systems listed in Ansible&#8217;s inventory file,
which defaults to /etc/ansible/hosts, and looks like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">mail</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
<span class="p">[</span><span class="n">webservers</span><span class="p">]</span>
<span class="n">foo</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
<span class="n">bar</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
<span class="p">[</span><span class="n">dbservers</span><span class="p">]</span>
<span class="n">one</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
<span class="n">two</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
<span class="n">three</span><span class="o">.</span><span class="n">example</span><span class="o">.</span><span class="n">com</span>
</pre></div>
</div>
</div>
2012-03-08 19:53:48 +01:00
<div class="section" id="selecting-targets">
<h2>Selecting Targets<a class="headerlink" href="#selecting-targets" title="Permalink to this headline"></a></h2>
<p>These patterns target all hosts in the inventory file:</p>
<div class="highlight-python"><pre>all
*</pre>
2012-03-08 19:36:47 +01:00
</div>
2012-03-08 19:53:48 +01:00
<p>It is also possible to address specific hosts:</p>
<div class="highlight-python"><pre>one.example.com
one.example.com:two.example.com</pre>
</div>
<p>The following patterns address one or more groups, which are denoted
with the bracket headers in the inventory file:</p>
2012-03-08 19:53:48 +01:00
<div class="highlight-python"><pre>webservers
webservers:dbservers</pre>
2012-03-08 19:36:47 +01:00
</div>
<p>Individual hosts, but not groups, can also be referenced using
wildcards:</p>
<div class="highlight-python"><pre>*.example.com
*.com</pre>
</div>
2012-03-08 19:53:48 +01:00
<p>It&#8217;s also ok to mix wildcard patterns and groups at the same time:</p>
<div class="highlight-python"><pre>one*.com:dbservers</pre>
2012-03-08 19:36:47 +01:00
</div>
2012-03-08 19:53:48 +01:00
<p>NOTE: It is not possible to target a host not in the inventory file.</p>
2012-03-08 19:36:47 +01:00
</div>
2012-03-07 17:35:18 +01:00
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-right"><a href="#">Back to top</a></p>
<p>
&copy; Copyright 2012 Michael DeHaan.<br/>
Last updated on Mar 09, 2012.<br/>
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.<br/>
</p>
</div>
</footer>
2012-03-07 17:35:18 +01:00
</body>
</html>