ycycoco 发表于 2018-1-2 21:05:12

ansible案例

- hosts: 172.16.1.201                          //目标主机  remote_user: root                           //远程主机用户
  tasks:
  - name: install epel-release                     //centos安装nginx前,需先安装epel-release
  command: yum install epel-release -y
  - name: install libselinux-python                  //利用ansible copy 文件需安装此包
  command: yum install libselinux-python -y
  - name: install nginx
  command: yum install nginx -y
  - name: copy html
  copy: src="templates/index.html.j2" dest="/usr/share/nginx/html/index.html"      //copy自定义html到指定目录
  tags: html
  notify:
  - server restart
  - name: server start
  service: name=nginx state=started enabled=true        //启动并设置开机启动服务
  handlers:
  - name: server restart
  service: name=nginx state=restarted
  
页: [1]
查看完整版本: ansible案例