yaml语法之 条件测试,循环,tags 介绍
条件测试
when语句:在tasks中使用。
[root@ansible ~]# vim test5.yaml - hosts: centos6-7 remote_user: root tasks: - name: install httpd yum: name=httpd state=latest - name: start centos6 httpd shell: service httpd start when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "6" --> facts变量 - name: start centos7 httpd shell: systemctl start httpd.service when: ansible_distribution == "CentOS" and ansible_distribution_majo