# Need help with ansible 2.7

**URL:** <https://forum.ansible.com/t/need-help-with-ansible-2-7/28728>\
**Category:** Ansible Project\
**Created:** [October 5, 2018, 2:44am UTC](https://forum.ansible.com/t/need-help-with-ansible-2-7/28728 "2018-10-05T02:44:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karthick\_Thanigaiman](https://avatars.discourse-cdn.com/v4/letter/k/aca169/32.png) [@Karthick\_Thanigaiman](https://forum.ansible.com/u/Karthick_Thanigaiman)\
**Post date:** [October 5, 2018, 2:44am UTC](https://forum.ansible.com/t/need-help-with-ansible-2-7/28728/1 "2018-10-05T02:44:23Z")

</div>

Hi,

We are using ansible 2.7 and in my yml file I ahave the below:

- include\_tasks: roles/common/tasks/os\_base.yml

- include\_tasks: roles/common/tasks/splunk\_base.yml

- include\_tasks:  
file: roles/common/tasks/splunk\_role.yml  
apply:  
splunkRole:

- splunk-clustermaster

but getting an error as

fatal: [localhost]: FAILED! =\> {“reason”: “‘splunkRole’ is not a valid attribute for a Block\n\nThe error appears to have been in ‘/home/ec2-user/splunk-infra/ansible/roles/clusterdeployer/tasks/main.yml’: line 10, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n apply:\n splunkRole:\n ^ here\n”}

Earlier we had ansible 2.6.4 and the below used to work but the ansible gets upgraded because of the way the setup is done and hence the issue.

- include\_tasks: roles/common/tasks/splunk\_role.yml splunkRole=splunk-clustermaster

can someone help please urgently?

Thank you

Regards  
Karthik

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 6, 2018, 7:39am UTC](https://forum.ansible.com/t/need-help-with-ansible-2-7/28728/2 "2018-10-06T07:39:24Z")

</div>

> Hi,
> 
> We are using ansible 2.7 and in my yml file I ahave the below:
> 
> - include\_tasks: roles/common/tasks/os\_base.yml  
> - include\_tasks: roles/common/tasks/splunk\_base.yml  
> - include\_tasks:  
> &nbsp;&nbsp;&nbsp;&nbsp;file: roles/common/tasks/splunk\_role.yml  
> &nbsp;&nbsp;&nbsp;&nbsp;apply:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;splunkRole:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- splunk-clustermaster
> 
> but getting an error as
> 
> fatal: [localhost]: FAILED! =\> {"reason": "'splunkRole' is not a valid  
> attribute for a Block\n\nThe error appears to have been in  
> '/home/ec2-user/splunk-infra/ansible/roles/clusterdeployer/tasks/main.yml':  
> line 10, column 7, but may\nbe elsewhere in the file depending on the exact  
> syntax problem.\n\nThe offending line appears to be:\n\n apply:\n  
> splunkRole:\n ^ here\n"}

The documentation say this about apply  
"Accepts a hash of task keywords..."

Keyword for task you'll find here  
[https://docs.ansible.com/ansible/2.7/reference\_appendices/playbooks\_keywords.html#task](https://docs.ansible.com/ansible/2.7/reference_appendices/playbooks_keywords.html#task)

and splunkRole is on the list.

> Earlier we had ansible 2.6.4 and the below used to work but the ansible  
> gets upgraded because of the way the setup is done and hence the issue.
> 
> - include\_tasks: roles/common/tasks/splunk\_role.yml  
> splunkRole=splunk-clustermaster

So you are trying to provide a variable called splunkRole, according to 2.6 and 2.7 documentation you need to use vars for that.  
[https://docs.ansible.com/ansible/2.6/user\_guide/playbooks\_reuse\_includes.html#including-and-importing-task-files](https://docs.ansible.com/ansible/2.6/user_guide/playbooks_reuse_includes.html#including-and-importing-task-files)

The syntax you are using was deprecated in Ansible 2.0  
[https://docs.ansible.com/ansible/devel/porting\_guides/porting\_guide\_2.0.html#deprecated](https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_2.0.html#deprecated)
