ansible/roles/nagios/tasks/main.yml
2020-07-23 23:13:16 -05:00

54 lines
1.5 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: Assure CNAME record
route53:
state: present
overwrite: yes
zone: "{{ zone }}"
type: CNAME
record: "{{ nagios_url }}"
ttl: 3600
value:
- "{{ inventory_hostname }}.{{ zone }}."
- 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 }}"
become: yes