Ansible multiple condition not working -
ansible version: 2.2.1.0
hostfile:
[master] 54.65.104.4 [slaves] 52.69.71.248
tasks/main.yaml
- name: checking if node having spark master installed (master) stat: path: /etc/init.d/spark-master register: spark-master when: inventory_hostname in groups['master'] - name: checking if node having spark worker installed stat: path: /etc/init.d/spark-slave register: spark-slave when: inventory_hostname in groups['slaves'] # downloading master - include: download.yaml when: (inventory_hostname in groups['master']) , ( spark-master.stat.exists == false) # downloading slaves - include: download.yaml when: (inventory_hostname in groups['slaves']) , ( spark-slave.stat.exists == false )
but when execute script receiving following errors:
fatal: [52.69.71.248]: failed! => {"failed": true, "msg": "the conditional check '(inventory_hostname in groups['slaves']) , ( spark-slave.stat.exists == false )' failed. error was: error while evaluating conditional ((inventory_hostname in groups['slaves']) , ( spark-slave.stat.exists == false )): 'slave' undefined\n\nthe error appears have been in '/opt/ansible-role-spark/tasks/download.yaml': line 2, column 3, may\nbe elsewhere in file depending on exact syntax problem.\n\nthe offending line appears be:\n\n---\n- name: download spark\n ^ here\n"}
can me in figuring mistake committing.
either quote condition, like:
when: "(inventory_hostname in groups['master']) , ( spark-master.stat.exists == false)"
or don't use parentheses.
Comments
Post a Comment