ansible/roles/nagios/tasks/main.yml

61 lines
1.7 KiB
YAML
Raw Normal View History

2020-07-23 23:13:16 -05:00
#!/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_short }}.{{ zone }}."
2020-07-23 23:13:16 -05:00
- 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 }}"
2020-07-24 03:25:31 -05:00
- name: Configure Nagios
block:
- name: Enable service
systemd:
name: nagios3
enabled: yes
state: started
2020-07-23 23:13:16 -05:00
become: yes