ansible部署zabbix客户端
2017-10-23 23:57
495 查看
Ansible简介:
ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。
ansible是基于模块工作的,本身没有批量部署的能力。真正具有批量部署的是ansible所运行的模块,ansible只是提供一种框架。主要包括:
(1)、连接插件connection plugins:负责和被监控端实现通信;
(2)、host inventory:指定操作的主机,是一个配置文件里面定义监控的主机;
(3)、各种模块核心模块、command模块、自定义模块;
(4)、借助于插件完成记录日志邮件等功能;
(5)、playbook:剧本执行多个任务时,非必需可以让节点一次性运行多个任务。
方案实施:
服务器:10.0.0.128
客户端:10.0.0.129
1.在服务器生成免密钥文件,推送到客户端
[root@ansible ~]# ssh-keygen
[root@ansible ~]# ssh-copy-id 10.0.0.129
2.安装ansible软件
[root@ansible ~]# yum install -y ansible
3.修改配置文件,添加模块,将zabbix客户端IP添加进去
[root@ansible ~]# cat /etc/ansible/hosts
[zabbix_client]
10.0.0.129
4.创建安装zabbix客户端的ansible-playbook
[root@ansible ~]# cat /etc/ansible/install_zabbix_client.yaml
[root@ansible ansible]# ansible-playbook -e server_ip=10.0.0.128 install_zabbix_client.yaml
##-e 选项里的` server_ip `是client指定的zabbix_server的IP
6.输出结果
[root@ansible ansible]# ansible-playbook -e server_ip=10.0.0.128 install_zabbix_client.yaml
PLAY [zabbix_client] ************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************
ok: [10.0.0.129]
TASK [copy] *********************************************************************************************************************************
ok: [10.0.0.129]
TASK [tar] **********************************************************************************************************************************
changed: [10.0.0.129]
TASK [useradd] ******************************************************************************************************************************
changed: [10.0.0.129]
TASK [yum] **********************************************************************************************************************************
ok: [10.0.0.129] => (item=[u'make', u'gcc', u'curl', u'curl-devel'])
TASK [configure] ****************************************************************************************************************************
changed: [10.0.0.129]
TASK [script] *******************************************************************************************************************************
changed: [10.0.0.129]
TASK [zabbix_agent] *************************************************************************************************************************
[WARNING]: Consider using template or lineinfile module rather than running sed
changed: [10.0.0.129]
TASK [conf files] ***************************************************************************************************************************
changed: [10.0.0.129]
TASK [restart_server] ***********************************************************************************************************************
changed: [10.0.0.129]
PLAY RECAP **********************************************************************************************************************************
10.0.0.129 : ok=10 changed=7 unreachable=0 failed=0
end!!!!!!!!
ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。
ansible是基于模块工作的,本身没有批量部署的能力。真正具有批量部署的是ansible所运行的模块,ansible只是提供一种框架。主要包括:
(1)、连接插件connection plugins:负责和被监控端实现通信;
(2)、host inventory:指定操作的主机,是一个配置文件里面定义监控的主机;
(3)、各种模块核心模块、command模块、自定义模块;
(4)、借助于插件完成记录日志邮件等功能;
(5)、playbook:剧本执行多个任务时,非必需可以让节点一次性运行多个任务。
方案实施:
服务器:10.0.0.128
客户端:10.0.0.129
1.在服务器生成免密钥文件,推送到客户端
[root@ansible ~]# ssh-keygen
[root@ansible ~]# ssh-copy-id 10.0.0.129
2.安装ansible软件
[root@ansible ~]# yum install -y ansible
3.修改配置文件,添加模块,将zabbix客户端IP添加进去
[root@ansible ~]# cat /etc/ansible/hosts
[zabbix_client]
10.0.0.129
4.创建安装zabbix客户端的ansible-playbook
[root@ansible ~]# cat /etc/ansible/install_zabbix_client.yaml
- hosts: zabbix_client remote_user: root tasks: - name: copy copy: src=/usr/local/src/zabbix-3.2.7.tar.gz dest=/usr/local/src/zabbix-3.2.7.tar.gz - name: tar shell: cd /usr/local/src;tar xf zabbix-3.2.7.tar.gz - name: useradd shell: useradd zabbix -s /sbin/nologin - name: yum yum: name={{ item }} state=latest with_items: - make - gcc - curl - curl-devel - name: configure shell: cd /usr/local/src/zabbix-3.2.7;./configure --with-net-snmp --with-libcurl --enable-agent --prefix=/usr/local/zabbix;make && make install - name: script shell: cp /usr/local/src/zabbix-3.2.7/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/ - name: zabbix_agent shell: sed -i 's/ZABBIX_BIN="\/usr\/local\/sbin\/zabbix_agentd"/ZABBIX_BIN="\/usr\/local\/zabbix\/sbin\/zabbix_agentd"/g' /etc/init.d/zabbix_agentd - name: conf files shell: sed -i 's/Server=127.0.0.1/Server={{ server_ip }}/g' /usr/local/zabbix/etc/zabbix_agentd.conf - name: restart_server shell: /etc/init.d/zabbix_agentd restart5.执行ansible-playbook
[root@ansible ansible]# ansible-playbook -e server_ip=10.0.0.128 install_zabbix_client.yaml
##-e 选项里的` server_ip `是client指定的zabbix_server的IP
6.输出结果
[root@ansible ansible]# ansible-playbook -e server_ip=10.0.0.128 install_zabbix_client.yaml
PLAY [zabbix_client] ************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************
ok: [10.0.0.129]
TASK [copy] *********************************************************************************************************************************
ok: [10.0.0.129]
TASK [tar] **********************************************************************************************************************************
changed: [10.0.0.129]
TASK [useradd] ******************************************************************************************************************************
changed: [10.0.0.129]
TASK [yum] **********************************************************************************************************************************
ok: [10.0.0.129] => (item=[u'make', u'gcc', u'curl', u'curl-devel'])
TASK [configure] ****************************************************************************************************************************
changed: [10.0.0.129]
TASK [script] *******************************************************************************************************************************
changed: [10.0.0.129]
TASK [zabbix_agent] *************************************************************************************************************************
[WARNING]: Consider using template or lineinfile module rather than running sed
changed: [10.0.0.129]
TASK [conf files] ***************************************************************************************************************************
changed: [10.0.0.129]
TASK [restart_server] ***********************************************************************************************************************
changed: [10.0.0.129]
PLAY RECAP **********************************************************************************************************************************
10.0.0.129 : ok=10 changed=7 unreachable=0 failed=0
end!!!!!!!!
相关文章推荐
- ansible 批量部署zabbix客户端
- ansible部署zabbix客户端
- ansible部署zabbix客户端
- ansible自动化部署zabbix客户端
- ansible 部署 zabbix客户端 脚本
- ansible - nagios和zabbix客户端的部署
- ANSIBLE部署ZABBIX客户端
- 通过Ansible 安装部署 TiDB 及将 TiDB作为Zabbix 的数据库
- centos安装部署zabbix监控服务端和客户端
- zabbix学习-如何部署一个agent客户端
- zabbix 1.8.5 客户端安装部署(Linux操作系统)
- centos6 ansible_playbook编译安装zabbix客户端
- centos6 zabbix_agentd客户端安装部署
- 一键部署Zabbix客户端
- ansible安装zabbix_agent客户端
- ansible 部署zabbix_agentd(分应用)
- linux 安装部署zabbix 客户端
- 运维自动化之ansible playbook安装zabbix客户端
- ansible安装配置zabbix客户端
- zabbix 客户端agent安装部署过程