[root@node1 playbook]# cat nginx.yml
- hosts: test  \\主机组,要和nginx.yml在同一个目录下
  remote_user: root  \\远端执行任务的用户
  tasks: \\任务
  - name: install httpd  \\任务描述
    command: yum -y install httpd  \\调用ansible的command模块安装httpd
  - name: provide httpd.conf \\任务描述
copy: src="/root/httpd.conf" dest="/etc/httpd/conf/httpd.conf" \\调用ansible的copy模块,httpd安装完成后将事先准备好的httpd.conf文件复制到/etc/httpd/conf目录下
    tags: conf  \\给此任务打标记,可单独执行标记的任务,使用 ansible-playbook -C 命令执行
    notify:  \\文件内容变更通知
    - server restart  \\通知到指定的任务
  - name: server start  \\任务描述
    service: name=httpd state=started enabled=true \\调用ansible的service模块的属性定义安装完成httpd以后httpd服务的管理
  handlers: \\定义接受关注的资源变化后执行的动作
  - name: server restart  \\任务描述
    service: name=httpd state=restarted   \\当关注的资源发生变化后调用service模块,采取的响应的动作

 

相关文章:

  • 2021-07-12
  • 2022-12-23
  • 2021-08-18
  • 2021-05-31
  • 2021-08-09
  • 2022-12-23
猜你喜欢
  • 2021-12-05
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
相关资源
相似解决方案