From 1f42fd9964cd0f178edaa4d1df68695379b4b3cf Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 22 Aug 2013 23:29:13 -0500 Subject: [PATCH] Remove references to old-style variables Fixes #3842 --- docsite/latest/rst/bestpractices.rst | 2 +- docsite/latest/rst/playbooks.rst | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/docsite/latest/rst/bestpractices.rst b/docsite/latest/rst/bestpractices.rst index b7eb9c1c91..e7616f7497 100644 --- a/docsite/latest/rst/bestpractices.rst +++ b/docsite/latest/rst/bestpractices.rst @@ -282,7 +282,7 @@ This makes a dynamic group of hosts matching certain criteria, even if that grou - hosts: all tasks: - - group_by: key=${ansible_distribution} + - group_by: key={{ ansible_distribution }} # now just on the CentOS hosts... diff --git a/docsite/latest/rst/playbooks.rst b/docsite/latest/rst/playbooks.rst index 148ee6c91f..a6d63ba2a3 100644 --- a/docsite/latest/rst/playbooks.rst +++ b/docsite/latest/rst/playbooks.rst @@ -147,13 +147,9 @@ The `vars` section contains a list of variables and values that can be used in t These variables can be used later in the playbook like this:: - $varname or ${varname} or {{ varname }} + {{ varname }} -If you ever want to do anything complex like uppercasing a string, {{ varname }} is best, as it uses the Jinja2 templating engine. It is a good idea to get in the habit of using this form most of the time when the output is to be a string. - -If just referencing the value of another simple variable though, it's fine to say $x or ${x}. This is common for when a datastructure has a member that is the value of another datastructure. - -To learn more about Jinja2, you can optionally see the `Jinja2 docs `_ - though remember that Jinja2 loops and conditionals are only for 'templates' in Ansible, in playbooks, ansible has the 'when' and 'with' keywords for conditionals and loops. +Variables are passed through the Jinja2 templating engine, and support the use of filters to modify the variable (for example: {{ varname|int }} ensures the variable is interpretted as an integer). To learn more about Jinja2, you can optionally see the `Jinja2 docs `_ - though remember that Jinja2 loops and conditionals are only for 'templates' in Ansible, in playbooks, ansible has the 'when' and 'with' keywords for conditionals and loops. If there are discovered variables about the system, called 'facts', these variables bubble up back into the playbook, and can be used on each system just like explicitly set variables. Ansible provides several of these, prefixed with 'ansible', which are documented under 'setup' in the module documentation. Additionally,