Question:
Each of the roles in my playbook ends with this code:
1 2 |
- include_tasks: includes/log_role_completion.yml this_role={{ role_name }} |
Which is used (at the end of the playbook) to write a log on the target server,
indicating when a PB was started (there’s a task at the start of the PB for that), what roles ran, and when (the start and end-times are the same, but that’s for another day).
The problem is that with Ansible 2.7, I’m now getting an error caused by the line above:
1 2 3 4 5 6 |
- include_tasks: includes/log_role_completion.yml this_role="{{ role_name }}" ^ here We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance: |
This worked up until 2.7, and is useful – I’d hate to have to lose it. I’ve tried putting quotes around the “includes…}}” part of the line, to no avail.
PS I know that Ansible can write logs – I find this more useful. Also, I’m aware that include_tasks is marked ‘preview’, so may change, but I can’t find release notes to tell me if it has.
Answer:
The usage has been changed in Ansible 2.7.
OLD In Ansible 2.6 (and earlier) the following was valid syntax for specifying variables:
1 2 |
- include_tasks: include_me.yml variable=value #the old way |
NEW In Ansible 2.7 the task should be changed to use the vars keyword:
1 2 3 4 |
- include_tasks: include_me.yml vars: variable: value |
Check out the Porting Guide for more details