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