ansible/roles/nagios/tasks/main.yml

51 lines
1.4 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: 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