playbook文件内容解释

[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模块,采取的响应的动作

 

相关文章

----name:setpublickeyonremotehosts&setreomtehostssud...
环境准备#cat/etcedhat-releaseCentOSLinuxrelease7.9.2009(...
准备好环境,在安装之前请先了解openshift提供的ansible有大...
Ansible:运维工作:系统安装(物理机、虚拟机)-->程序包...
ansible与salt对比相同都是为了同时在多台机器上执行相同的命...
[root@node1playbook]#catnginx.yml-hosts:test\\主...