ansible/roles/nagios/tasks/main.yml
2020-08-01 16:29:21 -05:00

51 lines
1.4 KiB
YAML

#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Install and configure Nagios
block:
- name: Install packages
block:
- name: Install Nagios package
apt:
name:
- nagios3
- name: Set up Apache
block:
- name: Enable modules
command:
cmd: a2enmod "{{ item }}"
creates: "/etc/apache2/mods-enabled/{{ item }}.load"
loop:
- cgi
- rewrite
notify: restart apache
- name: Assure admin user
htpasswd:
path: /etc/nagios3/htpasswd.users
name: "{{ nagios_user_name }}"
password: "{{ nagios_user_password }}"
notify: restart nagios
- name: Template out vhost
template:
src: "apache2-vhost-ssl.conf"
dest: "/etc/apache2/sites-available/{{ nagios_url }}.conf"
notify: restart apache
- name: Enable site
command:
cmd: "a2ensite {{ nagios_url }}.conf"
creates: "/etc/apache2/sites-enabled/{{ nagios_url }}.conf"
notify: restart apache
- name: Generate certificate
include_role:
name: https
vars:
website_url: "{{ nagios_url }}"
- name: Configure Nagios
block:
- name: Enable service
systemd:
name: nagios3
enabled: yes
state: started
become: yes