Repository: ansible/ansible
Pull request: Add porting guide note about inline vars on import/include_tasks
##### SUMMARY
Add porting guide note about inline vars on import/include_tasks. Fixes #47102
##### ISSUE TYPE
- Docs Pull Request
##### COMPONENT NAME
docs/docsite/rst/porting_guides/porting_guide_2.7.rst

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
2.7
2.8
```

##### ADDITIONAL INFORMATION
<!--- Include additional information to help people understand the change here -->
<!--- A step-by-step reproduction of the problem is helpful if there is no related issue -->

<!--- Paste verbatim command output below, e.g. before and after your change -->
```paste below

```

Problem statement:
2.7 breaks include_tasks with variables
##### SUMMARY
After upgrading to Ansible 2.7, our scripts stopped working. Looks like the behaviour of include_tasks was broken.

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
include_tasks

##### ANSIBLE VERSION
```
2.7
```

##### OS / ENVIRONMENT
Mac OS High Sierra

##### STEPS TO REPRODUCE
```yaml
tasks:
  - include_tasks: ../tasks/install-ruby.yml ruby_version=2.3.7
```

##### EXPECTED RESULTS
In 2.6, it used to load the tasks in the yml file, and ruby_version would be available for use via `{ruby_version}` within the install-ruby.yml file.

##### ACTUAL RESULTS
```
ERROR! Invalid options for include_tasks: ruby_version

The error appears to have been in '/Users/work/ansible/hosts/dev.yml': line 24, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    - include_tasks: ../tasks/install-ruby.yml ruby_version=2.3.7
      ^ here
```

Hints from issue discussion:
There appears to be no mention of this breakage in the changelog, and the documentation doesn't include any examples for this. Can someone provide me the up to date syntax please?
Ok, found this closed issue: https://github.com/ansible/ansible/issues/47071#issuecomment-429938205

So this works now:

```yaml
tasks:
  - include_tasks: ../tasks/install-ruby.yml
    vars:
      ruby_version: 2.3.7
```

Would be nice to have this change documented on the changelog. Would have saved me 30 minutes trying to find the solution :-)
Hi @KieranP, thank you for submitting this issue!

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: thank_submitter --->

Commit message: Add porting guide note about inline vars. Fixes #47102

Patch to review:
diff --git a/docs/docsite/rst/porting_guides/porting_guide_2.7.rst b/docs/docsite/rst/porting_guides/porting_guide_2.7.rst
index 6070419b3312b4..335dc162337916 100644
--- a/docs/docsite/rst/porting_guides/porting_guide_2.7.rst
+++ b/docs/docsite/rst/porting_guides/porting_guide_2.7.rst
@@ -71,6 +71,25 @@ In Ansible 2.7 a new module argument named ``public`` was added to the ``include
 
 There is an important difference in the way that ``include_role`` (dynamic) will expose the role's variables, as opposed to ``import_role`` (static). ``import_role`` is a pre-processor, and the ``defaults`` and ``vars`` are evaluated at playbook parsing, making the variables available to tasks and roles listed at any point in the play. ``include_role`` is a conditional task, and the ``defaults`` and ``vars`` are evaluated at execution time, making the variables available to tasks and roles listed *after* the ``include_role`` task.
 
+include_tasks/import_tasks inline variables
+```````````````````````````````````````````
+
+As of Ansible 2.7, `include_tasks` and `import_tasks` can no longer accept inline variables. Instead of using inline variables, tasks should supply variables under the ``vars`` keyword.
+
+**OLD** In Ansible 2.6 (and earlier) the following was valid syntax for specifying variables:
+
+.. code-block:: yaml
+
+    - include_tasks: include_me.yml variable=value
+
+**NEW** In Ansible 2.7 the task should be changed to use the ``vars`` keyword:
+
+.. code-block:: yaml
+
+    - include_tasks: include_me.yml
+      vars:
+        variable: value
+
 vars_prompt with unknown algorithms
 -----------------------------------
 


Code review comments:
diff_hunk: @@ -71,6 +71,25 @@ In Ansible 2.7 a new module argument named ``public`` was added to the ``include
 
 There is an important difference in the way that ``include_role`` (dynamic) will expose the role's variables, as opposed to ``import_role`` (static). ``import_role`` is a pre-processor, and the ``defaults`` and ``vars`` are evaluated at playbook parsing, making the variables available to tasks and roles listed at any point in the play. ``include_role`` is a conditional task, and the ``defaults`` and ``vars`` are evaluated at execution time, making the variables available to tasks and roles listed *after* the ``include_role`` task.
 
+include_tasks/import_tasks inline variables
+```````````````````````````````````````````
path: docs/docsite/rst/porting_guides/porting_guide_2.7.rst
text: @user1:
I can't tell whether you meant this to be a sub-section - if so, it's fine. If not, please make the heading match the others at this level (---------- instead of ``````````).

@author:
argh! completely accidental. I was in another file, and using backticks, and just did it without thinking.

@author:
addressed

@user1:
Thanks for the update. Looks good, merging.