You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* trailing newline When a string with a trailing newline was specified in the
55
59
playbook through yaml dict format, the trailing newline was stripped. When
56
60
specified in key=value format, the trailing newlines were kept. In v2, both
57
61
methods of specifying the string will keep the trailing newlines. If you
58
62
relied on the trailing newline being stripped, you can change your playbook
59
-
using the following as an example::
63
+
using the following as an example:
60
64
61
65
62
66
* Syntax in 1.9.x
@@ -168,17 +172,23 @@ Example of a recommended variant:
168
172
* Ranges specified in host patterns should use the [x:y] syntax, instead of [x-y].
169
173
* Playbooks using privilege escalation should always use "become*" options rather than the old su*/sudo* options.
170
174
* The "short form" for vars_prompt is no longer supported.
171
-
For example::
175
+
For example:
176
+
177
+
.. code-block:: yaml+jinja
172
178
173
179
vars_prompt:
174
180
variable_name: "Prompt string"
175
181
176
-
* Specifying variables at the top level of a task include statement is no longer supported. For example::
182
+
* Specifying variables at the top level of a task include statement is no longer supported. For example:
183
+
184
+
.. code-block:: yaml+jinja
177
185
178
186
- include_tasks: foo.yml
179
-
a: 1
187
+
a: 1
188
+
189
+
Should now be:
180
190
181
-
Should now be::
191
+
.. code-block:: yaml+jinja
182
192
183
193
- include_tasks: foo.yml
184
194
vars:
@@ -187,11 +197,15 @@ Should now be::
187
197
* Setting any_errors_fatal on a task is no longer supported. This should be set at the play level only.
188
198
* Bare variables in the `environment` dictionary (for plays/tasks/and so on) are no longer supported. Variables specified there should use the full variable syntax: '{{foo}}'.
189
199
* Tags (or any directive) should no longer be specified with other parameters in a task include. Instead, they should be specified as an option on the task.
190
-
For example::
200
+
For example:
201
+
202
+
.. code-block:: yaml+jinja
191
203
192
204
- include_tasks: foo.yml tags=a,b,c
193
205
194
-
Should be::
206
+
Should be:
207
+
208
+
.. code-block:: yaml+jinja
195
209
196
210
- include_tasks: foo.yml
197
211
tags: [a, b, c]
@@ -204,31 +218,41 @@ Other caveats
204
218
205
219
Here are some corner cases encountered when updating. These are mostly caused by the more stringent parser validation and the capture of errors that were previously ignored.
206
220
207
-
* Bad variable composition::
221
+
* Bad variable composition:
222
+
223
+
.. code-block:: yaml+jinja
208
224
209
225
with_items: myvar_{{rest_of_name}}
210
226
211
-
This worked 'by accident' as the errors were retemplated and ended up resolving the variable, it was never intended as valid syntax and now properly returns an error, use the following instead.::
227
+
This worked 'by accident' as the errors were retemplated and ended up resolving the variable, it was never intended as valid syntax and now properly returns an error, use the following instead.:
The task always ran without using privilege escalation (for that you need `become`) but was also silently ignored so the play 'ran' even though it should not, now this is a parsing error.
221
241
222
242
223
-
* Duplicate directives::
243
+
* Duplicate directives:
244
+
245
+
.. code-block:: yaml+jinja
224
246
225
247
- task: dostuf
226
248
when: True
227
249
when: False
228
250
229
251
The first `when` was ignored and only the 2nd one was used as the play ran w/o warning it was ignoring one of the directives, now this produces a parsing error.
230
252
231
-
* Conflating variables and directives::
253
+
* Conflating variables and directives:
254
+
255
+
.. code-block:: yaml+jinja
232
256
233
257
- role: {name=rosy, port=435 }
234
258
@@ -239,12 +263,16 @@ Here are some corner cases encountered when updating. These are mostly caused by
239
263
later in the play, this created issues if a host tried to reconnect or was using a non caching connection. Now it will be correctly identified as a directive and the `port` variable
240
264
will appear as undefined, this now forces the use of non conflicting names and removes ambiguity when adding settings and variables to a role invocation.
241
265
242
-
* Bare operations on `with_`::
266
+
* Bare operations on `with_`:
267
+
268
+
.. code-block:: yaml+jinja
243
269
244
270
with_items: var1 + var2
245
271
246
272
An issue with the 'bare variable' features, which was supposed only template a single variable without the need of braces ({{ )}}, would in some versions of Ansible template full expressions.
247
-
Now you need to use proper templating and braces for all expressions everywhere except conditionals (`when`)::
273
+
Now you need to use proper templating and braces for all expressions everywhere except conditionals (`when`):
Copy file name to clipboardExpand all lines: docs/docsite/rst/porting_guides/porting_guide_2.4.rst
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -152,7 +152,9 @@ automatically. In 2.4, users are responsible for escaping backslashes themselves
152
152
brings the template lookup plugin inline with the template module so that the same backslash
153
153
escaping rules apply to both.
154
154
155
-
If you have a template lookup like this::
155
+
If you have a template lookup like this:
156
+
157
+
.. code-block:: yaml+jinja
156
158
157
159
- debug:
158
160
msg: '{{ lookup("template", "template.j2") }}'
@@ -175,7 +177,9 @@ Tests
175
177
Tests succeeded/failed
176
178
-----------------------
177
179
178
-
Prior to Ansible version 2.4, a task return code of ``rc`` would override a return code of ``failed``. In version 2.4, both ``rc`` and ``failed`` are used to calculate the state of the task. Because of this, test plugins ``succeeded``/``failed``` have also been changed. This means that overriding a task failure with ``failed_when: no`` will result in ``succeeded``/``failed`` returning ``True``/``False``. For example::
180
+
Prior to Ansible version 2.4, a task return code of ``rc`` would override a return code of ``failed``. In version 2.4, both ``rc`` and ``failed`` are used to calculate the state of the task. Because of this, test plugins ``succeeded``/``failed``` have also been changed. This means that overriding a task failure with ``failed_when: no`` will result in ``succeeded``/``failed`` returning ``True``/``False``. For example:
Copy file name to clipboardExpand all lines: docs/docsite/rst/porting_guides/porting_guide_2.5.rst
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,12 +78,16 @@ The relevant change in those examples is, that in Ansible 2.5, the included file
78
78
Fixed handling of keywords and inline variables
79
79
-----------------------------------------------
80
80
81
-
We made several fixes to how we handle keywords and 'inline variables', to avoid conflating the two. Unfortunately these changes mean you must specify whether `name` is a keyword or a variable when calling roles. If you have playbooks that look like this::
81
+
We made several fixes to how we handle keywords and 'inline variables', to avoid conflating the two. Unfortunately these changes mean you must specify whether `name` is a keyword or a variable when calling roles. If you have playbooks that look like this:
You will run into errors because Ansible reads name in this context as a keyword. Beginning in 2.5, if you want to use a variable name that is also a keyword, you must explicitly declare it as a variable for the role::
88
+
You will run into errors because Ansible reads name in this context as a keyword. Beginning in 2.5, if you want to use a variable name that is also a keyword, you must explicitly declare it as a variable for the role:
Copy file name to clipboardExpand all lines: docs/docsite/rst/porting_guides/porting_guide_2.8.rst
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,15 +44,21 @@ Jinja Undefined values
44
44
Beginning in version 2.8, attempting to access an attribute of an Undefined value in Jinja will return another Undefined value, rather than throwing an error immediately. This means that you can now simply use
45
45
a default with a value in a nested data structure when you don't know if the intermediate values are defined.
{{ foo.bar.baz if (foo is defined and foo.bar is defined and foo.bar.baz is defined) else 'DEFAULT' }}
58
64
@@ -309,14 +315,18 @@ Become Prompting
309
315
310
316
Beginning in version 2.8, by default Ansible will use the word ``BECOME`` to prompt you for a password for elevated privileges (``sudo`` privileges on Unix systems or ``enable`` mode on network devices):
If you want the prompt to display the specific ``become_method`` you're using, instead of the general value ``BECOME``, set :ref:`AGNOSTIC_BECOME_PROMPT` to ``False`` in your Ansible configuration.
318
326
319
-
By default in Ansible 2.7, or with ``AGNOSTIC_BECOME_PROMPT=False`` in Ansible 2.8::
327
+
By default in Ansible 2.7, or with ``AGNOSTIC_BECOME_PROMPT=False`` in Ansible 2.8:
0 commit comments