[root@CASupport1 ~]# tree ansible ansible ├── get-pip.py ├── hosts ├── roles │ └── zabbix │ ├── default │ ├── files │ │ ├── tcp_status.conf │ │ ├── tcp_status.log │ │ └── tcp_status.sh │ ├── handlers │ ├── meta │ ├── tasks │ │ └── main.yml │ ├── template │ └── vars │ └── main.yml ├── site.retry └── site.yml 9 directories, 9 files [root@CASupport1 ~]# [root@CASupport1 ~]# cat roles/zabbix/tasks/main.yml - name: 拷贝tcp的脚本tcp_status.sh copy: src=tcp_status.sh dest={{ destsh }} mode=755 force=yes - name: 拷贝tcp的配置文件tcp_status.conf copy: src=tcp_status.conf dest={{ destconf }} force=yes - name: 创建目录{{ createdir }} file: dest={{ createdir }} state=directory force=no - name: 拷贝临时文件 tcp_status.log 权限zabbix copy: src=tcp_status.log dest={{ createdir }} mode=644 force=yes owner=zabbix group=zabbix - name: 重启 zabbix 客户端 service: name=zabbix-agent state=restarted [root@CASupport1 ~]# [root@CASupport1 ~]# cat hosts [efield] e0 e1 e2 e3 e4 [root@CASupport1 ~]# [root@CASupport1 ansible]# cat site.yml --- - name: Install zabbix template hosts: next become: True roles: - zabbix [root@CASupport1 ansible]# [root@CASupport1 ansible]# cat roles/zabbix/vars/main.yml destsh: /etc/zabbix/shell/ destconf: /etc/zabbix/zabbix_agentd.d/ createdir: /etc/zabbix/data/ [root@CASupport1 ansible]#
本文出自 “砖家博客” 博客,请务必保留此出处http://wsxxsl.blog.51cto.com/9085838/1906430
原文地址:http://wsxxsl.blog.51cto.com/9085838/1906430