Deploying zabbix-agent-4.0 with Ansible-playbook

Source: Internet
Author: User

- hosts: all remote_user: root tasks: - name: CentOS6 system copy zabbix-agent rpm copy: src=/tmp/zabbix-agent-3.4.9-1.el6.x86_64.rpm dest=/tmp/zabbix-agent-3.4.9-1.el6.x86_64.rpm when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "6" - name: CentOS7 system copy zabbix-agent rpm copy: src=/tmp/zabbix-agent-3.4.9-1.el7.x86_64.rpm dest=/tmp/zabbix-agent-3.4.9-1.el7.x86_64.rpm when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "7" - name: yum install zabbix-agent shell: cd /tmp;yum -y localinstall zabbix-agent-3.4.*.rpm - name: rm zabbix-agent shell: cd /tmp;rm -rf zabbix-agent-3.*.rpm - name: configure Server IP shell: sed -i ‘s/Server=127.0.0.1/Server=192.168.58.58/‘ /etc/zabbix/zabbix_agentd.conf - name: configure ServerActive IP shell: sed -i ‘s/ServerActive=127.0.0.1/ServerActive=192.168.58.58/‘ /etc/zabbix/zabbix_agentd.conf - name: configure HostMetadata shell: sed -i ‘s/# HostMetadata=/HostMetadata=qas/‘ /etc/zabbix/zabbix_agentd.conf - name: CentOS6 system configure Hostname shell: host=`ifconfig |awk -F ‘[ :]+‘ ‘NR==2 {print $4}‘`;sed -i ‘s/Hostname=Zabbix server/Hostname=‘$host‘/‘ /etc/zabbix/zabbix_agentd.conf when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "6" - name: CentOS7 system configure Hostname shell: host=`ifconfig |awk -F ‘[ :]+‘ ‘NR==2 {print $3}‘`;sed -i ‘s/Hostname=Zabbix server/Hostname=‘$host‘/‘ /etc/zabbix/zabbix_agentd.conf when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "7" - name: CentOS6 system start zabbix shell: /etc/init.d/zabbix-agent start;chkconfig zabbix-agent on when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "6" - name: CentOS7 system start zabbix shell: systemctl enable zabbix-agent.service;systemctl restart zabbix-agent.service when: - ansible_distribution == "CentOS" - ansible_distribution_major_version == "7"




Git repository address

Https://github.com/xgh2016/ansible-zabbix


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.