mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
260 lines
9.3 KiB
HTML
260 lines
9.3 KiB
HTML
13 years ago
|
|
||
|
<!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" />
|
||
|
|
||
13 years ago
|
<title>YAML Format — Ansible v0.0.1 documentation</title>
|
||
13 years ago
|
<link rel="stylesheet" href="_static/default.css" type="text/css" />
|
||
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
||
13 years ago
|
<link rel="stylesheet" href="_static/bootstrap.css" type="text/css" />
|
||
|
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
|
||
13 years ago
|
<script type="text/javascript">
|
||
|
var DOCUMENTATION_OPTIONS = {
|
||
|
URL_ROOT: '',
|
||
|
VERSION: '0.0.1',
|
||
|
COLLAPSE_INDEX: false,
|
||
|
FILE_SUFFIX: '.html',
|
||
13 years ago
|
HAS_SOURCE: false
|
||
13 years ago
|
};
|
||
|
</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>
|
||
13 years ago
|
<script type="text/javascript" src="_static/bootstrap-dropdown.js"></script>
|
||
|
<script type="text/javascript" src="_static/bootstrap-scrollspy.js"></script>
|
||
13 years ago
|
<link rel="top" title="Ansible v0.0.1 documentation" href="index.html" />
|
||
13 years ago
|
<link rel="next" title="Playbooks" href="playbooks.html" />
|
||
|
<link rel="prev" title="Ansible Modules" href="modules.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();
|
||
|
});
|
||
|
}());
|
||
13 years ago
|
</script>
|
||
|
<script type="text/javascript">
|
||
|
|
||
|
var _gaq = _gaq || [];
|
||
|
_gaq.push(['_setAccount', 'UA-29861888-1']);
|
||
|
_gaq.push(['_trackPageview']);
|
||
|
|
||
|
(function() {
|
||
|
var ga = document.createElement('script'); ga.type =
|
||
|
'text/javascript'; ga.async = true;
|
||
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
|
||
|
'http://www') + '.google-analytics.com/ga.js';
|
||
|
var s = document.getElementsByTagName('script')[0];
|
||
|
s.parentNode.insertBefore(ga, s);
|
||
|
})();
|
||
|
|
||
13 years ago
|
</script>
|
||
|
|
||
13 years ago
|
</head>
|
||
|
<body>
|
||
13 years ago
|
<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">
|
||
13 years ago
|
<li class="toctree-l1"><a class="reference internal" href="gettingstarted.html">Downloads & Getting Started</a></li>
|
||
13 years ago
|
<li class="toctree-l1"><a class="reference internal" href="patterns.html">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 current"><a class="current reference internal" href="">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>
|
||
13 years ago
|
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li>
|
||
13 years ago
|
<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="#">YAML Format</a><ul>
|
||
|
<li><a class="reference internal" href="#yaml-basics">YAML Basics</a></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</span>
|
||
|
</li>
|
||
|
|
||
|
|
||
13 years ago
|
|
||
13 years ago
|
<li><a href="modules.html"
|
||
|
title="previous chapter">« Ansible Modules</a></li>
|
||
|
<li><a href="playbooks.html"
|
||
|
title="next chapter">Playbooks »</a></li>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
</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>
|
||
|
|
||
13 years ago
|
|
||
|
<a href="https://github.com/ansible/ansible"><img
|
||
|
style="position: absolute; top: 40px; right: 0; border: 0;"
|
||
|
src="https://a248.e.akamai.net/assets.github.com/img/71eeaab9d563c2b3c590319b398dd35683265e85/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67"
|
||
|
alt="Fork me on GitHub"
|
||
|
alt="Fork me on GitHub"></a>
|
||
13 years ago
|
<div class="container">
|
||
|
|
||
13 years ago
|
<div class="section" id="yaml-format">
|
||
|
<h1>YAML Format<a class="headerlink" href="#yaml-format" title="Permalink to this headline">¶</a></h1>
|
||
13 years ago
|
<p>This page provides a basic overview of correct YAML syntax, which is how Ansible
|
||
|
playbooks (our configuration management language) are expressed.
|
||
|
You may also wish to read playbook examples and will quickly pick this up from those.</p>
|
||
13 years ago
|
<div class="section" id="yaml-basics">
|
||
|
<h2>YAML Basics<a class="headerlink" href="#yaml-basics" title="Permalink to this headline">¶</a></h2>
|
||
13 years ago
|
<p>For <cite>ansible</cite>, every YAML file must be a list at it’s root-most
|
||
13 years ago
|
element. Each item in the list is a dictionary. These dictionaries
|
||
13 years ago
|
represent all the options you can use to write an <cite>ansible</cite> file. In
|
||
13 years ago
|
addition, all YAML files (regardless of their association with
|
||
|
<cite>ansible</cite> or not) should start with <tt class="docutils literal"><span class="pre">---</span></tt>.</p>
|
||
|
<p>In YAML a list can be represented in two ways. In one way all members
|
||
13 years ago
|
of a list are lines beginning at the same indentation level starting
|
||
13 years ago
|
with a <tt class="docutils literal"><span class="pre">-</span></tt> character:</p>
|
||
|
<div class="highlight-python"><pre>---
|
||
|
# A list of tasty fruits
|
||
|
- Apple
|
||
|
- Orange
|
||
|
- Strawberry
|
||
|
- Mango</pre>
|
||
|
</div>
|
||
|
<p>In the second way a list is represented as comma separated elements
|
||
|
surrounded by square brackets. Newlines are permitted between
|
||
|
elements:</p>
|
||
|
<div class="highlight-python"><pre>---
|
||
|
# A list of tasty fruits
|
||
|
[apple, orange, banana, mango]</pre>
|
||
|
</div>
|
||
|
<p>A dictionary is represented in a simple <tt class="docutils literal"><span class="pre">key:</span></tt> and <tt class="docutils literal"><span class="pre">value</span></tt> form:</p>
|
||
|
<div class="highlight-python"><pre>---
|
||
|
# An employee record
|
||
|
name: John Eckersberg
|
||
|
job: Developer
|
||
|
skill: Elite</pre>
|
||
|
</div>
|
||
|
<p>Like lists, dictionaries can be represented in an abbreviated form:</p>
|
||
|
<div class="highlight-python"><pre>---
|
||
|
# An employee record
|
||
|
{name: John Eckersberg, job: Developer, skill: Elite}</pre>
|
||
|
</div>
|
||
|
<p id="truthiness">You can specify a boolean value (true/false) in several forms:</p>
|
||
|
<div class="highlight-python"><pre>---
|
||
|
knows_oop: True
|
||
|
likes_emacs: TRUE
|
||
|
uses_cvs: false</pre>
|
||
|
</div>
|
||
|
<p>Finally, you can combine these data structures:</p>
|
||
|
<div class="highlight-python"><pre>---
|
||
|
# An employee record
|
||
|
name: John Eckersberg
|
||
|
job: Developer
|
||
|
skill: Elite
|
||
|
employed: True
|
||
|
foods:
|
||
|
- Apple
|
||
|
- Orange
|
||
|
- Strawberry
|
||
|
- Mango
|
||
|
languages:
|
||
|
ruby: Elite
|
||
|
python: Elite
|
||
|
dotnet: Lame</pre>
|
||
|
</div>
|
||
|
<p>That’s all you really need to know about YAML to get started writing
|
||
13 years ago
|
<cite>Ansible</cite> playbooks.</p>
|
||
13 years ago
|
<div class="admonition-see-also admonition seealso">
|
||
|
<p class="first admonition-title">See also</p>
|
||
|
<dl class="last docutils">
|
||
|
<dt><a class="reference external" href="http://yamllint.com/">YAMLLint</a></dt>
|
||
|
<dd>YAML Lint gets the lint out of your YAML</dd>
|
||
|
</dl>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
</div>
|
||
13 years ago
|
<footer class="footer">
|
||
|
<div class="container">
|
||
|
<p class="pull-right"><a href="#">Back to top</a></p>
|
||
|
<p>
|
||
|
© Copyright 2012 Michael DeHaan.<br/>
|
||
13 years ago
|
Last updated on Mar 10, 2012.<br/>
|
||
13 years ago
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.8.<br/>
|
||
13 years ago
|
</p>
|
||
|
</div>
|
||
|
</footer>
|
||
13 years ago
|
</body>
|
||
|
</html>
|