This guide provides a complete Ansible playbook to install Adagios from available packages with proper configuration as a web interface for Nagios/Naemon monitoring.
Current Adagios version: Varies by distribution
Create a file named adagios.yml:
---
- name: Install and Configure Adagios
hosts: adagios
become: true
vars:
adagios_port: 80
adagios_config_dir: "/etc/adagios"
nagios_config_dir: "/etc/nagios"
adagios_user: "www-data"
adagios_admin_password: "adagios_admin_123" # Change this!
tasks:
- name: Install Adagios (Debian/Ubuntu)
apt:
name:
- adagios
- adagios-core
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install prerequisites (RHEL/CentOS)
yum:
name:
- nagios
- nagios-plugins
- php
- php-gd
- php-mbstring
state: present
when: ansible_os_family == "RedHat"
- name: Download and install Adagios (RHEL/CentOS)
shell: |
wget -O /tmp/adagios.rpm https://github.com/op5/adagios/releases/download/1.6.1/adagios-1.6.1-1.el8.x86_64.rpm &&
yum install -y /tmp/adagios.rpm
args:
creates: /usr/share/adagios
when: ansible_os_family == "RedHat"
- name: Create Adagios configuration directory
file:
path: "{{ adagios_config_dir }}"
state: directory
owner: root
group: root
mode: '0755'
- name: Configure Adagios settings
copy:
dest: "{{ adagios_config_dir }}/adagios.conf"
owner: root
group: root
mode: '0644'
content: |
# Adagios Configuration
NAGIOS_CONFIG_FILE={{ nagios_config_dir }}/nagios.cfg
NAGIOS_STATE_FILE=/var/nagios/status.dat
NAGIOS_COMMAND_FILE=/var/nagios/rw/nagios.cmd
NAGIOS_LOG_FILE=/var/nagios/nagios.log
ADAGIOS_LOG_FILE=/var/log/adagios/adagios.log
ADAGIOS_TEMPLATE_DIR=/usr/share/adagios/templates
DEFAULT_HOSTGROUP=linux-servers
DEFAULT_SERVICEGROUP=
AUTHENTICATED_USERS=admin
ANONYMOUS_USERS=
- name: Configure Apache for Adagios (Debian/Ubuntu)
copy:
dest: /etc/apache2/sites-available/adagios.conf
owner: root
group: root
mode: '0644'
content: |
<VirtualHost *:{{ adagios_port }}>
ServerName {{ ansible_fqdn | default(ansible_hostname) }}
DocumentRoot /usr/share/adagios
<Directory /usr/share/adagios>
Options None
AllowOverride None
Require all granted
AuthType Basic
AuthName "Adagios Access"
AuthUserFile {{ adagios_config_dir }}/htpasswd
Require valid-user
</Directory>
<Directory /usr/share/adagios/rest>
AuthType Basic
AuthName "Adagios API"
AuthUserFile {{ adagios_config_dir }}/htpasswd
Require valid-user
</Directory>
</VirtualHost>
when: ansible_os_family == "Debian"
- name: Enable Adagios site (Debian/Ubuntu)
command: a2ensite adagios
args:
creates: /etc/apache2/sites-enabled/adagios.conf
when: ansible_os_family == "Debian"
- name: Create htpasswd file for Adagios admin
htpasswd:
path: "{{ adagios_config_dir }}/htpasswd"
name: admin
password: "{{ adagios_admin_password }}"
owner: root
group: root
mode: '0640'
- name: Set proper permissions on Nagios command file
file:
path: /var/nagios/rw/nagios.cmd
owner: "{{ nagios_user | default('nagios') }}"
group: "{{ adagios_user }}"
mode: '0660'
failed_when: false
- name: Restart Apache (Debian/Ubuntu)
systemd:
name: apache2
enabled: true
state: restarted
when: ansible_os_family == "Debian"
- name: Restart httpd (RHEL/CentOS)
systemd:
name: httpd
enabled: true
state: restarted
when: ansible_os_family == "RedHat"
- name: Configure firewall (UFW)
ufw:
rule: allow
port: "{{ adagios_port }}"
proto: tcp
comment: "Adagios web interface"
when: ansible_os_family == "Debian"
failed_when: false
- name: Configure firewall (firewalld)
firewalld:
service: "{{ item }}"
permanent: true
immediate: true
state: enabled
loop:
- http
- https
when: ansible_os_family == "RedHat"
failed_when: false
- name: Verify Adagios installation
command: adagios --version
register: adagios_check
changed_when: false
failed_when: false
- name: Display Adagios status
debug:
msg: |
Adagios installed successfully!
Web Interface: http://{{ ansible_default_ipv4.address | default(ansible_host) }}/adagios/
Username: admin
Password: {{ adagios_admin_password }}
IMPORTANT: Change the default password after first login!
Configuration directory: {{ adagios_config_dir }}
---
adagios:
hosts:
adagios-server:
ansible_host: 192.168.1.126
ansible_user: ansible
ansible_become: true
# Test connectivity
ansible all -i inventory.yml -m ping
# Run the Adagios playbook
ansible-playbook -i inventory.yml adagios.yml
# Run with custom admin password
ansible-playbook -i inventory.yml adagios.yml \
-e "adagios_admin_password=MySecureP@ss123"
# Check Adagios version
ssh adagios-server "adagios --version"
# Test web interface
curl -I http://adagios-server/adagios/
# Access web UI
# http://adagios-server/adagios/
# Check Apache logs
sudo tail -f /var/log/apache2/error.log
# Check Adagios logs
sudo tail -f /var/log/adagios/adagios.log
# Verify Nagios config
sudo nagios -v /etc/nagios/nagios.cfg
# Check command file permissions
ls -la /var/nagios/rw/nagios.cmd
# Fix permissions
sudo chown nagios:www-data /var/nagios/rw/nagios.cmd
sudo chmod 660 /var/nagios/rw/nagios.cmd
We develop tailored automation solutions for:
Let’s discuss your requirements: office@linux-server-admin.com | Contact