I have written separate playbooks for tomcat deployment on both Ubuntu and Linux as well, instead of mentioning **
when: ansible_distribution == 'Ubuntu'
**in every line in the playbook, i want to run the whole playbook only when this condition meets.
This is my code
- hosts: all
tasks:
- name: including the playbook for ubuntu deployment
include: tomcat_ubuntu_new.yaml
when: ansible_distribution == 'Ubuntu'
- name: including the playbook for ubuntu deployment
include: tomcat_standalone.yaml
when: ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat'
Error:
ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>
The error appears to be in '/etc/ansible/tomcat_ubuntu_new.yaml': line 3, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- hosts: all
^ here
I want to run the playbook only on the hosts based on the ansible_distribution
I tried many ways but no one works can any one post a clear answer with explanation
/etc/ansible/tomcat_ubuntu_new.yaml
, i would inspect that file too.