标签:roo hand image load enc mic ati handlers res
简单例子1: vars定义变量
- hosts: all remote_user: root vars: - package: nginx - service: nginx tasks: - name: install nginx package yum: name={{ package }} state=latest - name: install configuration file for httpd copy: src=/etc/nginx/nginx.conf dest=/etc/nginx/nginx.conf notify: - restart nginx?- name: start httpd service service: enabled=true name={{ service }} state=startedhandlers:- name: restart nginx service: name={{ package }} state=restarted
条件测试: when条件测试
- hosts: all remote_user: root vars: - username: user2 tasks: - name: create {{ username }} user user: name={{ username }} when: ansible_distribution == "CentOS"
迭代
ansible-playbook(2)
原文地址:https://www.cnblogs.com/c040/p/10358084.html