安装zabbix-agent2之ansible-playbook
zabbix被监控端安装zabbix-agent2之ansible-playbook
---
- name: install agent
hosts: all
vars:
server_host: "192.168.100.206"
tasks:
- shell: "rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm ; dnf clean all"
when: ansible_distribution_file_variety == "RedHat" and ansible_distribution_major_version == "8"
- shell: "rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-4.el7.noarch.rpm ; yum clean all"
when: ansible_distribution_file_variety == "RedHat" and ansible_distribution_major_version == "7"
- shell: "wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-4%2Bubuntu20.04_all.deb; dpkg -i zabbix-release_6.0-4+ubuntu20.04_all.deb "
when: ansible_distribution_file_variety == "Debian" and ansible_distribution_major_version == "20"
- yum:
name:
- "zabbix-agent2"
- "zabbix-agent2-plugin-mongodb"
disable_gpg_check: yes
state: present
when: ansible_distribution_file_variety == "RedHat"
- apt:
name:
- "zabbix-agent2"
- "zabbix-agent2-plugin-mongodb"
update_cache: yes
state: present
when: ansible_os_family == "Debian"
- replace:
path: /etc/zabbix/zabbix_agent2.conf
regexp: 'Server=127.0.0.1'
replace: "Server={{ server_host }}"
- service:
name: zabbix-agent2
state: restarted
enabled: yes
本文来自博客园,作者:大雨转暴雨,转载请注明原文链接:https://www.cnblogs.com/wdy001/p/16750592.html