2021-09-07 14:27:23 -05:00
|
|
|
#!/usr/bin/env ansible-playbook
|
|
|
|
# vim:ft=ansible:
|
|
|
|
---
|
|
|
|
- hosts: tags_nagios
|
2022-02-15 15:19:34 -06:00
|
|
|
gather_facts: no
|
2021-09-07 14:27:23 -05:00
|
|
|
roles:
|
|
|
|
- role: git
|
|
|
|
vars:
|
|
|
|
git_repos:
|
|
|
|
- repo: https://git.desu.ltd/salt/monitoring-scripts
|
|
|
|
dest: /usr/local/bin/monitoring-scripts
|
2021-09-14 17:22:50 -05:00
|
|
|
tags: [ nagios, git ]
|
2021-09-07 14:27:23 -05:00
|
|
|
tasks:
|
|
|
|
- name: assure nagios plugin packages
|
|
|
|
apt: name=monitoring-plugins,nagios-plugins-contrib
|
|
|
|
tags: [ nagios ]
|
|
|
|
- name: assure nagios user
|
|
|
|
user: name=nagios-checker state=present system=yes
|
|
|
|
tags: [ nagios ]
|
|
|
|
- name: assure nagios user ssh key
|
|
|
|
authorized_key:
|
|
|
|
user: nagios-checker
|
|
|
|
state: present
|
|
|
|
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKNavw28C0mKIQVRLQDW2aoovliU1XCGaenDhIMwumK/ Nagios monitoring"
|
|
|
|
tags: [ nagios ]
|
2021-12-15 19:57:08 -06:00
|
|
|
- name: assure nagios user sudo rule file
|
|
|
|
file: path=/etc/sudoers.d/50-nagios-checker mode=0750 owner=root group=root state=touch modification_time=preserve access_time=preserve
|
|
|
|
tags: [ nagios, sudo ]
|
|
|
|
- name: assure nagios user sudo rules
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/sudoers.d/50-nagios-checker
|
|
|
|
line: "nagios-checker ALL = (root) NOPASSWD: {{ item }}"
|
|
|
|
with_items:
|
|
|
|
- /usr/lib/nagios/plugins/check_disk
|
2022-01-11 18:30:27 -06:00
|
|
|
- /usr/local/bin/monitoring-scripts/check_docker
|
2022-01-10 22:14:07 -06:00
|
|
|
- /usr/local/bin/monitoring-scripts/check_temp
|
2021-12-15 19:57:08 -06:00
|
|
|
tags: [ nagios, sudo ]
|
2021-09-07 14:27:23 -05:00
|
|
|
- hosts: all
|
2022-02-15 15:19:34 -06:00
|
|
|
gather_facts: no
|
2021-09-07 14:27:23 -05:00
|
|
|
tasks:
|
|
|
|
- name: disable nagios user when not tagged
|
|
|
|
user: name=nagios-checker state=absent remove=yes
|
|
|
|
when: "'tags_nagios' not in group_names"
|
|
|
|
tags: [ nagios ]
|