mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-10-24 15:05:54 +00:00
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
requestsmodule - Access to the nginx configuration files
Role Variables
health_nginx_folder: The folder where thehealth-nginxscript 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
- Installation of Python Modules: The role installs the required Python
requestsmodule. - File and Directory Management: It creates the necessary directories and files, including the
health-nginx.pyscript. - Service and Timer Templates: Templates for
health-nginx.cymais.serviceandhealth-nginx.cymais.timerare set up to automate the health checks. - Running the Health Check: The
health-nginx.pyscript 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.serviceif there are any changes to the service file. - restart health-nginx.cymais.timer: Restarts and enables the
health-nginx.cymais.timerto schedule regular health checks.
Additional Information
- For more details on nginx configurations, visit nginx documentation.
- Learn more about Ansible's
uri_modulehere.
Contributions
This role was created with the assistance of ChatGPT. The conversation can be found here and here.