zoukankan      html  css  js  c++  java
  • Ansible:playbook-nagios

    一、创建目录结构
      
    cd /etc/ansible/roles/
    mkdir nagios/{files,templates,vars,handlers,meta,default,tasks} -pv
    二、files/:存储由copy或script等模块调用的文件;
      放入libexec  nrpe-2.12.tar.gz  nrpe.cfg
     
    三、tasks/:配置main.yml文件,用于定义各task;其它的文件需要由main.yml进行“包含”调用;
      

    - name: install tools
    shell: yum -y install openssl-devel*;yum -y install xinetd;yum -y install sysstat

    - name: copy package
    copy: src=nrpe-2.12.tar.gz dest=/usr/src/nrpe-2.12.tar.gz
    tags: cppkg

    - name: tar nrpe
    shell: cd /usr/src;tar -xf nrpe-2.12.tar.gz

    - name: install nrpe
    shell: useradd nagios;cd /usr/src/nrpe-2.12;sh configure --prefix=/usr/local/nagios;make;make install-daemon;make install-daemon-config;make install-xinetd;make install

    - name: xinetd
    replace: dest=/etc/xinetd.d/nrpe regexp='127.0.0.1' replace="10.11.16.215"

    - name: services
    shell: echo "nrpe 5666/tcp" >> /etc/services

    - name: restart xinetd
    shell: service xinetd restart

    - name: copy libexec
    copy: src=libexec/ dest=/usr/local/nagios/libexec/

    - name: copy nrpe.cfg
    copy: src=nrpe.cfg dest=/usr/local/nagios/etc/nrpe.cfg

    - name: chown
    shell: chown -R nagios:nagios /usr/local/nagios/libexec;chmod +x /usr/local/nagios/libexec/*;chown -R nagios:nagios /usr/local/nagios/etc/nrpe.cfg;

     
    四、定义一个主调用文件
    /etc/ansible/nagios/nagios_agent.yaml
    - hosts: CBS-VM
      remote_user: root
      roles: 
        - nagios
    五、检测语法
    ansible-playbook --syntax-check /etc/ansible/nagios/nagios_agent.yaml
    六、测试部署
    ansible-playbook -C /etc/ansible/nagios/nagios_agent.yaml
    -C 测试
    七、部署
    ansible-playbook /etc/ansible/nagios/nagios_agent.yaml
     
     
     
  • 相关阅读:
    PHP抓取页面的几种方式
    MySQL性能优化的最佳20+条经验
    linux下导入、导出mysql数据库命令
    8个必备的PHP功能开发
    jquery中的children()和contents()的区别
    centos 通用开发工具及库安装 有了它不用愁了
    将bat批处理文件注册成windows服务
    squid隐藏squid的版本号
    squid如何屏蔽User-Agent为空的请求
    RHEL/CentOS 6.x使用EPEL6与remi的yum源安装MySQL 5.5.x
  • 原文地址:https://www.cnblogs.com/suminem/p/11778747.html
Copyright © 2011-2022 走看看