一:ansible-playbook的基本语法 #编写以下yaml文件 [root @supervisor yaml]# cat /etc/ansible/yaml/test.yml --- - hosts: all remote_user: root tasks: - name: 安装ntpdate,wget,lrzsz yum: state=present name=ntpdate,wget,lrzsz - name: 创建web目录 shell: mkdir -p /data/cache - name: 安装httpd yum: state=present name=httpd notify: - Start httpd handlers: - name: Start httpd service: state=restarted name=httpd enabled=yes - hosts: centos7 remote_user: root tasks: - name: 安装net工具 yum: state=present name=net-tools #检查语法是否正确 [root @supervisor yaml]# ansible-playbook -i /etc/ansible/hosts /etc/ansible/yaml/test.yml --syntax