---
- 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. JavaWeb学习day7-Response初学3(重定向)

    重定向:web资源收到客户端请求后,通知客户端去访问另外一个web资源 1 protected void doGet(HttpServletRequest req, HttpServletRespon ...

  2. mmdetection训练出现nan

    训练出现nan 在使用MMDetection训练模型时,发现打印信息中出现了很多nan.现象是,loss在正常训练下降的过程中,突然变为nan. 梯度裁减 在模型配置中加上grad_clip: opt ...

  3. 超耐心地毯式分析,来试试这道看似简单但暗藏玄机的Promise顺序执行题

    壹 ❀ 引 就在昨天,与朋友聊到JS基础时,她突然想起之前在面试时,遇到了一道难以理解的Promise执行顺序题.由于我之前专门写过手写promise的文章,对于部分原理也还算了解,出于兴趣我便要了这 ...

  4. 分布式存储之GlusterFS

    公众号关注 「开源Linux」 回复「学习」,有我为您特别筛选的学习资料~ 1.glusterfs概述 GlusterFS系统是一个可扩展的网络文件系统,相比其他分布式文件系统,GlusterFS具有 ...

  5. 10个 Linux 命令,让你的操作更有效率

    点击上方"开源Linux",选择"设为星标" 回复"学习"获取独家整理的学习资料! 根据老九大师兄口头阐述,Linux是最适合开发的操作系统 ...

  6. Linux系统句柄优化

    Linux系统句柄介绍 文件句柄,会随着进程数增加而增加.其实Linux是有文件句柄限制的,而且Linux默认一般都是1024.在生产环境中很容易到达这个值,因此这里就会成为系统的瓶颈. 在Linux ...

  7. 探索ABP的EventHub解决方案

    在上一章中,我们构建了一个简单的全栈 Web 应用程序,我们已经看到了使用 ABP 框架开发应用的典型流程,在接下来,我们将使用 ABP 框架创建更高级的应用程序. 给出具有现实世界复杂性的例子并不容 ...

  8. HttpResponse,render,redirect,静态文件配置,request对象方法,pycharm连接MySQL,django连接MySQL,django ORM

    HttpResponse 主要用于返回字符串类型的数据 def index(request): return HttpResponse('index页面') 在页面中就会显示 index页面 rend ...

  9. netty系列之:netty中常用的字符串编码解码器

    目录 简介 netty中的字符串编码解码器 不同平台的换行符 字符串编码的实现 总结 简介 字符串是我们程序中最常用到的消息格式,也是最简单的消息格式,但是正因为字符串string太过简单,不能附加更 ...

  10. 【java并发编程】Lock & Condition 协调同步生产消费

    一.协调生产/消费的需求 本文内容主要想向大家介绍一下Lock结合Condition的使用方法,为了更好的理解Lock锁与Condition锁信号,我们来手写一个ArrayBlockingQueue. ...