cd /etc/ansible/roles/
mkdir nagios/{files,templates,vars,handlers,meta,default,tasks} -pv
- name: install tools shell : yum -y install openssl-devel*;yum -y install xinetd - 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 shell: src=libexec/ dest=/usr/local/nagios/libexec/ - name: copy nrpe.cfg shell: src=nrpe.cfg dest=/usr/local/nagios/etc/nrpe.cfg
- 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
ansible-playbook /etc/ansible/nagios/nagios_agent.yaml
原文:https://www.cnblogs.com/suminem/p/11778747.html