On 05.10.2018 04:44, karthick t wrote:
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"}

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

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

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

--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f8daece4b0f0aff2684be67b62d4b530%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to