---
- hosts: linux
tasks:
- name: copy centos 7 zabbix-agent2
copy: src=zabbix-agent2-5.0.11-1.el7.x86_64.rpm dest=/root
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
- name: install centsos 7 agent2
shell: rpm -ivh /root/zabbix-agent2-5.0.11-1.el7.x86_64.rpm
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
- name: copy centos 6 agent2
copy: src=zabbix-agent2-5.0.11-1.el6.x86_64.rpm dest=/root
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "6"
- name: install centos 6 agent2
shell: rpm -ivh /root/zabbix-agent2-5.0.11-1.el6.x86_64.rpm
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "6"
- name:
shell: cp /etc/zabbix/zabbix_agent2.conf /etc/zabbix/zabbix_agent2.conf.bak && sed -i 's/127.0.0.1/172.20.100.99/g' /etc/zabbix/zabbix_agent2.conf
notify: restart zabbix-agent2 handlers:
- name: restart zabbix-agent2
service: name=zabbix-agent2 enabled=yes state=started
zabbix下载地址:http://repo.zabbix.com/zabbix/5.0
ansible-playbook -l linux zabbix.yml
在windows上批量安装zabbix-agent2
下载地址:zabbix-agent2下载地址:https://cdn.zabbix.com/zabbix/binaries/stable/5.0/5.0.11/zabbix_agent2-5.0.11-windows-amd64-openssl-static.zip 在windows上执行以下命令:
winrm quickconfig
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"} 或者写成脚本在powershell执行
@ECHO off
winrm quickconfig -q -force
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"}
New-NetFirewallRule -Name Ansible -DisplayName Ansible -Enabled True -Action Allow -Protocol TCP -LocalPort 5985 -Direction InBound
PAUSE 防火墙放开5985端口
---
- hosts: all
tasks:
- name: Firewall rule to allow ansible om tcp port 5985
action: win_firewall_rule
args:
name: ansible
enabled: yes
state: present
localport: 5985
action: allow
protocol: Tcp
执行ansible-playbook -l windows win_rule_5985.yml
或者ansible-playbook -i hosts windows win_rule_5985.yml
ansible-playbook -i hosts win_rule_5985.yml -e hosts=windows
---
- hosts: Ali-windows
remote_user: Administrator
vars:
zabbix_server_ip: 59.37.126.227
tasks:
- name: create zabbix-agent2 dir
win_file:
path: C:zabbix-agent2
state: directory - name: copy zabbix-agent2 file
win_template: src=/etc/ansible/windows/roles/zabbix/templates/zabbix_agent2.conf dest=C:\zabbix-agent2\ - name: copy zabbix-agent2
win_copy: src=zabbix_agent2.exe dest=C:\zabbix-agent2\ - name: Install windows zabbix-agent2
#win_package:
# path: C:\zabbix_agent2-5.0.11-windows-amd64-openssl.msi
#Zabbix server IP: zabbix_server_ip
#arguments:
#- /install
#- /norestart
#state: present
win_command: zabbix_agent2.exe -i -c C:\zabbix-agent2\zabbix_agent2.conf
args:
chdir: C:\zabbix-agent2\ - name: start zabbix-agent2
win_command: zabbix_agent2.exe -s -c C:\zabbix-agent2\zabbix_agent2.conf
args:
chdir: C:\zabbix-agent2\ - name: Firewall rule to allow zabbix-agent2 om tcp port 10050
action: win_firewall_rule
args:
name: zabbix-agent2
enabled: yes
state: present
localport: 10050
action: allow
protocol: Tcp

 

  

  

ansible在linux和windows批量部署zabbix-agent2的更多相关文章

  1. Linux服务之批量部署篇

    批量部署步骤: 1.检查环境 getenforce               #检查内核防火墙是否关闭 systemctl status firewalld       #检查firewalld是否 ...

  2. 关于Linux和Windows下部署mysql.data.dll的注册问题

    mysql ado.net connector下载地址: http://dev.mysql.com/downloads/connector/net/ 选择版本: Generally Available ...

  3. 在Windows上部署Zabbix客户端

    将Zabbix for Windows客户端拷贝到windows系统的c盘,修改配置文件的相关配置项后,打开cmd窗口执行: # 安装服务 c:\zabbix\bin\win32\zabbix_age ...

  4. 使用Playbook批量部署多台LAMP环境

    1. 安装ansible yum install epel-release -y yum install ansible -y Playbook是一个不同于使用ansible命令行执行方式的模式,功能 ...

  5. 使用Cobbler批量部署Linux和Windows:Cobbler服务端部署(一)

    本文记录了我使用Cobbler批量安装部署Linux和Windows系统的过程,文章主要分为三部分:Cobbler服务端的安装配置.Linux发行版CentOS和Ubuntu的自动安装部署.Windo ...

  6. (转)使用Cobbler批量部署Linux和Windows:Cobbler服务端部署(一)

    原文:http://www.cnblogs.com/pluse/p/8316914.html http://blog.51cto.com/dreamway/1166589---------Cobble ...

  7. Ansible实现zabbix服务器agent端批量部署

    项目需求:由于搭建zabbix,需要每台服务器都需要安装监控端(agent)正常的的操作是一台一台去安装,这样确实有点浪费时间,这里为大家准备了一款开源 的自动化运维工具Ansible,相信大家也很熟 ...

  8. 利用ansible批量部署zabbix-agent

    应用环境:Linux运维工作少不了一个好的监控,zabbix就是目前比较好的一款开源监控软件. 监控类型多种多样,如果不介意或者系统支持安装,那么agent方式是首选. 当主机数量较多时,可以利用相关 ...

  9. 通过ansible自动化部署zabbix应用

    zabbix在实际的应用中,可能需要监控的主机非常多,而每个主机的操作系统类型.版本也都不尽相同,在这种环境下,通过手动安装zabbix的agent端已经不现实了,此时就需要借助自动化工具完成zabb ...

随机推荐

  1. 软件工程web课程第一次实验作业

    开头总结 本次作业使用html+css+js实现了一个简单页面 最终我要记录的是使用js完成了轮播图中图片背景的转换 <script> window.onload = function ( ...

  2. 从零搭建Pytorch模型教程(三)搭建Transformer网络

    ​ 前言 本文介绍了Transformer的基本流程,分块的两种实现方式,Position Emebdding的几种实现方式,Encoder的实现方式,最后分类的两种方式,以及最重要的数据格式的介绍. ...

  3. mouseenter 和 mouseover 的区别

    当鼠标移动到元素上时就会触发mouseenter事件 类似mouseover,它们两者之间的差别是 mouseover鼠标经过自身盒子会触发,经过子盒子还会触发.mouseenter只会经过自身盒子触 ...

  4. No value specified for 'Date' BeanUtils.copyProperties 日期为空 转型错误

    BEGIN; 最近在用spring data,使用的hibernate实现,然后用了一对多等关系配置,导致PO类转换JSON时会死循环,最后使用VO接受数据解决该问题.PO与VO相互转换我用的是org ...

  5. HTML续集

    计算机中PC:电脑 移动端:智能手机/智能电脑 html:超文本标记语言 图片标签<img src=" "> 图片的格式类型都有哪些? jpg,peg,gif(动图) ...

  6. 2. flddler响应显示乱码问题解决方案

    Fiddler是一款强大Web调试工具,它能记录所有客户端和服务器的HTTP请求. Fiddler启动的时候,默认IE的代理设为了127.0.0.1:8888,而其他浏览器是需要手动设置.但是一开始使 ...

  7. 攻防世界-MISC:base64stego

    这是攻防世界新手练习区的第十一题,题目如下: 点击下载附件一,发现是一个压缩包,点击解压,发现是需要密码才能解密 先用010editor打开这个压缩包,这里需要知道zip压缩包的组成部分,包括压缩源文 ...

  8. [AcWing 796] 子矩阵的和

    点击查看代码 #include<iostream> using namespace std; const int N = 1e3 + 10; int a[N][N], s[N][N]; i ...

  9. Linux常用命令格式

    Linux命令格式 命令 选项 参数COMMAND [OPTIONS...] [ARGUMENTS...]COMMAND COMMAND COMMAND .... 选项:用于启用或关闭命令的某个或某些 ...

  10. Redis进阶知识一览

    Redis的持久化机制 RDB: Redis DataBase 什么是RDB RDB∶每隔一段时间,把内存中的数据写入磁盘的临时文件,作为快照,恢复的时候把快照文件读进内存.如果宕机重启,那么内存里的 ...