Configuring Zabbix clients with Ansible installation

Source: Internet
Author: User
Tags vars

Ansible Role Description:

Directory name Description
Defaults Default Variable Storage directory
Handlers Handlers (actions to be taken when a change occurs)
Meta Role dependency Processing
Tasks Task action definition for specific execution
Templates Template file storage Directory
VARs Variable file directory
Files Install package file directory

1. View the Ansible control-side directory structure, tree/etc/ansible

/etc/ansible/├──ansible.cfg├──delete_zabbix_agent.yml├──hosts├──install_ Zabbix_agent.yml└──roles├──delete_zabbix_agent│  ├──tasks│  │  └──main.ym l│  └──vars│  └──main.yml└──install_zabbix_agent├──files│ & nbsp └──zabbix -2.2 . 1 . tar  .GZ├──TASKS│  └──MAIN.YML├──TEMPLATES│ &N Bsp ├──ZABBIX_AGENTD│  └──ZABBIX_AGENTD.CONF└──VARS└──MAIN.YML 
# ansible.cfg  This file is Ansible's main profile # hosts        used to define host group # roles        define different roles # INSTALL_ZABBIX_AGENT.YML  for installing Zabbix _agent boot File # delete_zabbix_agent.yml   Remove the boot file for the installed Zabbix_agent
# files directory: For installation packages that will be copied to the remote host, etc.
# Tasks Directory: All the tasks that will be performed, if complex, can define different tasks separately, and then refer to them in main.yml pieces.
# Templates Directory: Template directory, where some variable files are stored
# VARs directory: for storing variables

2.INSTALL_ZABBIX_AGENT.YML File Contents

- hosts:host  roles:  -Install_zabbix_agent

3.DELETE_ZABBIX_AGENT.YML File Contents

- hosts:host  roles:    -Delete_zabbix_agent

4./ETC/ANSIBLE/ROLES/INSTALL_ZABBIX_AGENT/TASKS/MAIN.YML File Contents

-Name:InstallSoftwareYum: Name={{item}} state=Latest With_items:
-Libcurl-libcurl-devel-name:create Zabbix User User:name={{zabbix_user}} state=present shell=/sbin/Nologin-Name:uncompression Zabbix.Tar. GZ unarchive:src=zabbix-{{zabbix_version}}.Tar. GZ dest={{Zabbix_dir}}-name:copy Zabbix Start Script template:src=zabbix_agentd dest=/etc/rc.d/init.d/zabbix_agentd owner=root group=root mode=0755-name:copy Zabbix Configfiletemplate:src=zabbix_agentd.conf dest={{zabbix_dir}}/zabbix/etc/zabbix_agentd.conf Owner={{zabbix_user}} Group={{zabbix_user}} Mode=0644-Name:modify ZabbixdirPermissionfile: Path={{zabbix_dir}}/zabbix Owner={{zabbix_user}} Group={{zabbix_user}} recurse=Yes-name:start Zabbix Service Shell:/etc/init.d/zabbix_agentd start

5. Copy zabbix-2.2.1.tar.gz, to/etc/ansible/roles/install_zabbix_agent/files/zabbix-2.2.1.tar.gz

6. Copy zabbix_agentd Start command file, go to/etc/ansible/roles/install_zabbix_agent/templates/zabbix_agentd directory, modify

# zabbix-Directory        #BASEDIR=/usr/local        BASEDIR={{zabbix_dir}}/zabbix 

7. Copy zabbix_agentd.conf configuration file, to/etc/ansible/roles/install_zabbix_agent/templates/zabbix_agentd.conf, modify

Server={{zabbix_server_ip}}serveractive={{zabbix_server_ip}

8./ETC/ANSIBLE/ROLES/INSTALL_ZABBIX_AGENT/VARS/MAIN.YML File Contents

Zabbix_dir:/usr/2.2. 1  1005010.205. 16.10

9./ETC/ANSIBLE/ROLES/DELETE_ZABBIX_AGENT/TASKS/MAIN.YML File Contents

-name:stop zabbix_agent shell:pgrep zabbix_agentd|Xargs KillIgnore_errors:yes-name:delete Boot Start shell:chkconfig--del Zabbix_agentd-name:delete Start Script Shell:RM-rf/etc/init.d/Zabbix_agentd-name:delete Install Dir Shell:RM-RF {{Zabbix_dir}}/Zabbix-name:delete software Shell:RM-RF {{Zabbix_dir}}/src/zabbix-{{zabbix_version}}.Tar. GZ-name:delete Log File Shell:RM-rf/tmp/Zabbix_agentd.log-name:delete Zabbix User user:name={{Zabbix_user}} state=absent Remove=yes

10./ETC/ANSIBLE/ROLES/DELETE_ZABBIX_AGENT/VARS/MAIN.YML File Contents

Zabbix_dir:/usr/2.2. 1 Zabbix_user:zabbix

11. Execute the command to install the Zabbix client

Ansible-playbook/etc/ansible/install_zabbix_agent.yml

12. Execute the command to delete the Zabbix client

Ansible-playbook/etc/ansible/delete_zabbix_agent.yml

Configuring Zabbix clients with Ansible installation

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.