天天看點

ansible 部署 zabbix用戶端 腳本

[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: efield
  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]#      

繼續閱讀