Ansible +centos7 Zabbix agent is not in bulk
Deploying Machine 192.168.4.100-116
Zabbix Server ip192.168.4.117
Ansible Structure Description
.├── hosts # Deploying client Machines ├── roles│ └── zabbix_agent│ ├── defaults│ ├── files│ ├── handlers│ ├── meta│ ├── tasks│ │ └── main.yml # ansible Deployment Zabbix_agent Script │ ├── templates│ │ └── zabbix_agentd.conf.j2 # zabbix_agent Configuration Files │ └── vars└── zabbix_agent.yml # ansible Control Script
zabbix_agent.yml content description- hosts: code user: Root vars: zabbix_serverip: 192.168.4.117 # zabbix Server ip zabbix_activeip: 192.168.4.117 # zabbix Server IP agent_ip: ' {{ ansible_eth0.ipv4.address } ' # client IP Change your network card name eth0 to your own server roles: - zabbix_agent
main.yml Content Description- name: yum epel-release # installation zabbix yum source must be yum: name=epel-release state=present- name: zabbix-release-3.2-1.el7.noarch.rpm get_url: url: #下载zabbix yum Source Configuration dest: /tmp/zabbix-release-3.2-1.el7.noarch.rpm- name: rpm -qi zabbix-release-3.2-1.el7.noarch shell: rpm -qi zabbix-release-3.2-1.el7.noarch # to see if the server is installing Zabbix3.2 register: result ignore_errors: true- name: zabbix-release-3.2-1.el7.noarch.rpm shell: rpm -uvh /tmp/ zabbix-release-3.2-1.el7.noarch.rpm # installation zabbix Source code when: result.rc == 1 - name: yum install zabbix-agent yum: name={{ item }} state=present # installation Zabbix-agent with_items: - zabbix-agent - zabbix-get - zabbix-sender- lineinfile: dest=/etc/services line= " Zabbix-agent 10050/tcp zabbix agent "- lineinfile: dest=/etc/services line=" Zabbix-agent 10050/udp zabbix agent " # add zabbix port to services file- name: up zabbix-agent file client # Uploading configuration Files template: src= zabbix_agentd.conf.j2 dest=/etc/zabbix/zabbix_agentd.conf- name: enabled service zabbix-agent # Open zabbix-agent Boot service: name=zabbix-agent.service enabled=yes- name: start service zabbix-agent # Start zabbix-agent service: name=zabbix-agent state=started
Other instructions:
Ansible-playbook-i hosts Zabbix_agent.yml-verbose
This article is from the "Growth record" blog, so be sure to keep this source http://juestnow.blog.51cto.com/1515305/1878420
Ansible +centos7 Batch Installation zabbix3.2.1 Agent