[[email protected] ~]# 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 [[email protected] ~]# [[email protected] ~]# 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 [[email protected] ~]# [[email protected] ~]# cat hosts [efield] e0 e1 e2 e3 e4 [[email protected] ~]# [[email protected] ansible]# cat site.yml --- - name: Install zabbix template hosts: next become: True roles: - zabbix [[email protected] ansible]# [[email protected] ansible]# cat roles/zabbix/vars/main.yml destsh: /etc/zabbix/shell/ destconf: /etc/zabbix/zabbix_agentd.d/ createdir: /etc/zabbix/data/ [[email protected] ansible]#
时间: 2024-10-11 14:35:51