首页 > 其他分享 >ansible推送zabbix控制端的palybook

ansible推送zabbix控制端的palybook

时间:2022-08-17 16:44:57浏览次数:48  
标签:palybook name server zabbix ansible conf mysql shell

main.yml文件 
- name: "下载数据包"
    get_url:
      url: "https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb"
      dest: "/root"

  - name : "安装下载包"
    shell: "dpkg -i zabbix-release_5.0-1+focal_all.deb"
  
  - name: "修改源"
    replace:
      path: "/etc/apt/sources.list.d/zabbix.list"
      regexp: "http://repo.zabbix.com"
      replace: "https://mirror.tuna.tsinghua.edu.cn/zabbix"
  
  - name: update
    shell:
      cmd: apt update
       
  - name: install packages
    apt: 
     name: "zabbix-server-mysql,zabbix-frontend-php,zabbix-nginx-conf,zabbix-agent2,mysql-server"

  - name: "创建mysql用户"
    script:
      cmd: /opt/mysql.sh

      
  - name: "导入mysql数据"
    shell: zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p123456  zabbix
    
  - name: "修改nginx配置文件"
    template:
      src: nginx.conf.j2
      dest: /etc/zabbix/nginx.conf      
  
  - name: "修改zabbix配置文件"
    template:
      src: zabbix_server.conf.j2
      dest: /etc/zabbix/zabbix_server.conf

  - name: "修改php配置文件"
    template:
      src: php-fpm.conf.j2
      dest: /etc/zabbix/php-fpm.conf
  
  - name: restart apache2
    shell: systemctl disable --now apache2
  
  - name: restart server
    shell: systemctl restart  zabbix-server zabbix-agent2 nginx php7.4-fpm
  
  - name: restart zabbix
    shell: systemctl enable   zabbix-server

中间引用的mysql.sh脚本
cat << EOF | mysqlcreate database zabbix character set utf8 collate utf8_bin; create user zabbix@localhost identified by '123456'; grant all privileges on zabbix.* to zabbix@localhost;EOF

 

标签:palybook,name,server,zabbix,ansible,conf,mysql,shell
From: https://www.cnblogs.com/smlience/p/16595765.html

相关文章

  • Zabbix
    一、系统环境准备 1、关闭防火墙systemctlstopfirewalld&&systemctldisablefirewalld 2、关闭SELinuxa.临时关闭:输入命令setenforce0,重启系统后还会开启。......
  • 【自动化运维专题 4】ansible的 playbook 使用及举例
    1.playbook简介  ansible的单条使命叫ad-hoc,将多条命令写在一块进行执行叫playbook。playbook,即剧本,现实中由演员按照剧本表演,在Ansible中,这次由计算机进行表演,由......
  • 【自动化运维专题1】ansible的安装和配置及使用准备
    1.环境准备现准备3台机器,一台作为控制节点,安装ansible,另外两台作为被管理节点,不需安装ansible。主机名IP地址节点类型系统版本ansible-control192.168.250.245控......
  • Ansible语法学习与总结
    【强烈推荐】Ansible自动化运维入门实战点击关注......
  • Ansible 命令模块操作
    目录Ansible命令模块操作Ansible清单部署Ansible清单文件静态清单INI格式定义嵌套组静态清单示例通过规范简化主机规格验证清单覆盖清单的位置在清单中定义变量Ansibl......