Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ansible/ansible.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'docs/docsite/rst/porting_guides/porting_guide_2.0.rst')
-rw-r--r--docs/docsite/rst/porting_guides/porting_guide_2.0.rst59
1 files changed, 47 insertions, 12 deletions
diff --git a/docs/docsite/rst/porting_guides/porting_guide_2.0.rst b/docs/docsite/rst/porting_guides/porting_guide_2.0.rst
index 9efa1b810a9..876ca5e27e9 100644
--- a/docs/docsite/rst/porting_guides/porting_guide_2.0.rst
+++ b/docs/docsite/rst/porting_guides/porting_guide_2.0.rst
@@ -21,16 +21,26 @@ Playbook
This section discusses any changes you may need to make to your playbooks.
+* Syntax in 1.9.x
+
.. code-block:: yaml
- # Syntax in 1.9.x
- debug:
msg: "{{ 'test1_junk 1\\\\3' | regex_replace('(.*)_junk (.*)', '\\\\1 \\\\2') }}"
- # Syntax in 2.0.x
+
+
+* Syntax in 2.0.x
+
+.. code-block:: yaml
+
- debug:
msg: "{{ 'test1_junk 1\\3' | regex_replace('(.*)_junk (.*)', '\\1 \\2') }}"
- # Output:
+
+* Output:
+
+.. code-block:: yaml
+
"msg": "test1 1\\3"
To make an escaped string that will work on all versions you have two options::
@@ -48,7 +58,11 @@ uses key=value escaping which has not changed. The other option is to check for
relied on the trailing newline being stripped, you can change your playbook
using the following as an example::
- # Syntax in 1.9.x
+
+ * Syntax in 1.9.x
+
+ .. code-block:: yaml
+
vars:
message: >
Testing
@@ -57,7 +71,11 @@ uses key=value escaping which has not changed. The other option is to check for
- debug:
msg: "{{ message }}"
- # Syntax in 2.0.x
+
+ * Syntax in 2.0.x
+
+ .. code-block:: yaml
+
vars:
old_message: >
Testing
@@ -65,7 +83,12 @@ uses key=value escaping which has not changed. The other option is to check for
message: "{{ old_message[:-1] }}"
- debug:
msg: "{{ message }}"
- # Output
+
+
+ * Output
+
+ .. code-block:: yaml
+
"msg": "Testing some things"
* Behavior of templating DOS-type text files changes with Ansible v2.
@@ -75,7 +98,9 @@ uses key=value escaping which has not changed. The other option is to check for
* When specifying complex args as a variable, the variable must use the full jinja2
variable syntax (```{{var_name}}```) - bare variable names there are no longer accepted.
In fact, even specifying args with variables has been deprecated, and will not be
- allowed in future versions::
+ allowed in future versions:
+
+.. code-block:: yaml
---
- hosts: localhost
@@ -87,7 +112,7 @@ uses key=value escaping which has not changed. The other option is to check for
- { path: /tmp/3b, state: directory, mode: 0700 }
tasks:
- file:
- args: "{{item}}" # <- args here uses the full variable syntax
+ args: "{{item}}"
with_items: "{{my_dirs}}"
* porting task includes
@@ -111,7 +136,9 @@ While all items listed here will show a deprecation warning message, they still
* Bare variables in ``with_`` loops should instead use the ``"{{ var }}"`` syntax, which helps eliminate ambiguity.
* The ansible-galaxy text format requirements file. Users should use the YAML format for requirements instead.
* Undefined variables within a ``with_`` loop's list currently do not interrupt the loop, but they do issue a warning; in the future, they will issue an error.
-* Using dictionary variables to set all task parameters is unsafe and will be removed in a future version. For example::
+* Using dictionary variables to set all task parameters is unsafe and will be removed in a future version. Example of a deprecated variant:
+
+.. code-block:: yaml
- hosts: localhost
gather_facts: no
@@ -119,14 +146,22 @@ While all items listed here will show a deprecation warning message, they still
debug_params:
msg: "hello there"
tasks:
- # These are both deprecated:
- debug: "{{debug_params}}"
- debug:
args: "{{debug_params}}"
- # Use this instead:
+Example of a recommended variant:
+
+.. code-block:: yaml
+
+ - hosts: localhost
+ gather_facts: no
+ vars:
+ debug_params:
+ msg: "hello there"
+ tasks:
- debug:
- msg: "{{debug_params['msg']}}"
+ msg: "{{debug_params['msg']}}"
* Host patterns should use a comma (,) or colon (:) instead of a semicolon (;) to separate hosts/groups in the pattern.
* Ranges specified in host patterns should use the [x:y] syntax, instead of [x-y].