computer-playbook/roles/health-nginx
Kevin Veen-Birkenbach 81c0aacec5 Changed 401 to 404 of listmonk 2024-02-07 22:28:05 +01:00
..
handlers Added .cymais.service suffix to make cymais files more visible 2024-01-10 11:18:38 +01:00
meta Changed systemd-notifier namings 2023-12-03 11:24:17 +01:00
tasks Added .cymais.service suffix to make cymais files more visible 2024-01-10 11:18:38 +01:00
templates Changed 401 to 404 of listmonk 2024-02-07 22:28:05 +01:00
vars optimized variable names 2023-11-17 12:35:39 +01:00
README.md Changed suffix to .cymais.timer 2024-01-10 11:26:00 +01:00

README.md

health-nginx

Overview

health-nginx is an Ansible role designed to send health reports for nginx configurations. It leverages Python scripting to check the status of nginx server configurations and reports back any issues. This role is especially useful for maintaining the health of nginx servers in a dynamic environment.

Requirements

  • Ansible
  • Python with the requests module
  • Access to the nginx configuration files

Role Variables

  • health_nginx_folder: The folder where the health-nginx script and related files are stored. Defaults to "{{ path_administrator_scripts }}health-nginx/".

Dependencies

This role depends on:

  • python-pip: For installing Python packages.
  • systemd-notifier: For notifying systemd in case of any failures.

Example Playbook

- hosts: servers
  roles:
    - { role: health-nginx }

Usage

  1. Installation of Python Modules: The role installs the required Python requests module.
  2. File and Directory Management: It creates the necessary directories and files, including the health-nginx.py script.
  3. Service and Timer Templates: Templates for health-nginx.cymais.service and health-nginx.cymais.timer are set up to automate the health checks.
  4. Running the Health Check: The health-nginx.py script is executed to perform the health check. It iterates over nginx configuration files and sends a HEAD request to each domain/subdomain to verify its status. The script considers different expected status codes based on the domain or subdomain.

Handler Details

  • reload health-nginx.cymais.service: Reloads the health-nginx.cymais.service if there are any changes to the service file.
  • restart health-nginx.cymais.timer: Restarts and enables the health-nginx.cymais.timer to schedule regular health checks.

Additional Information

Contributions

This role was created with the assistance of ChatGPT. The conversation can be found here and here.