我也为Ubuntu和Linux上的tomcat部署编写了单独的剧本,没有提及**
当:ansible_distribution =='Ubuntu'
**在剧本的每一行中,我只希望在满足此条件时才运行整个剧本。
这是我的代码
- 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! 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
我只想基于ansible_distribution在主机上运行剧本
我尝试了很多方法,但是没有人可以发表清晰的答案并给出解释
Q:“我只想基于ansible_distribution在主机上运行剧本。”