Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible 2.7 include_tasks no longer accepts a variable

Tags:

ansible

Each of the roles in my playbook ends with this code:

- 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:

- 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.

like image 837
Graham Nicholls Avatar asked Oct 18 '18 11:10

Graham Nicholls


1 Answers

The usage has been changed in Ansible 2.7.

OLD In Ansible 2.6 (and earlier) the following was valid syntax for specifying variables:

- 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:

- include_tasks: include_me.yml
  vars:
    variable: value

Check out the Porting Guide for more details

like image 134
kenlukas Avatar answered Oct 19 '22 07:10

kenlukas