Initial commit

This commit is contained in:
KsmoinO 2021-05-24 16:20:54 +02:00
commit 777e672179
8 changed files with 137 additions and 0 deletions

39
defaults/main.yaml Normal file
View file

@ -0,0 +1,39 @@
---
tinystatus_bindir: /opt/tinystatus
tinystatus_configdir: /etc/tinystatus
tinstatus_gitrepo: https://github.com/bderenzo/tinystatus
tinystatus_webdir: /var/www/html
tinystatus_pagefile: index.html
tinystatus_webuser: nginx
tinystatus_webgrp: nginx
tinystatus_user: nobody
tinystatus_grp: nobody
tinystatus_checks:
- name: Google Website
type: http
code: 200
host: https://google.com
- name: Google Website (IPv4)
type: http4
code: 200
host: https://google.com
- name: Google Website (IPv6)
type: http6
code: 200
host: https://google.com
- name: Google 404
type: http
code: 404
host: https://google.com/dummy
- name: Google ping
type: ping
code: 0
host: 8.8.8.8
- name: Google DNS
type: port
code: 0
host: 8.8.8.8 53
tinystatus_incidents: []
tinystatus_Timer_OnCalendar: "*-*-* *:00/10:00"
tinystatus_RandomizedDelaySec: 300

5
handlers/main.yml Normal file
View file

@ -0,0 +1,5 @@
---
- name: systemd daemon-reload
systemd:
daemon-reload: yes

66
tasks/main.yml Normal file
View file

@ -0,0 +1,66 @@
---
- name: Installation des prérequis
yum:
name:
- git
state: present
- name: Clonage du dépôt
git:
repo: "{{ tinstatus_gitrepo }}"
dest: "{{ tinystatus_bindir }}"
force: yes
- name: Mise en place du contectexte selinux
file:
path: "{{ tinystatus_bindir }}/tinystatus"
setype: bin_t
- name: Création du répertoire de configuration
file:
state: directory
path: "{{ tinystatus_configdir }}"
mode: 0555
- name: Déployment des fichiers de configuration
template:
src: "{{ item }}.j2"
dest: "{{ tinystatus_configdir }}/{{ item }}"
mode: 0444
loop:
- checks.csv
- incidents.txt
- name: Création du scritp d'éxécution
template:
src: tinystatus.sh.j2
dest: "{{ tinystatus_bindir }}/tinystatus.sh"
mode: 0555
setype: bin_t
- name: Création des fichiers systemd
template:
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
mode: 0644
loop:
- tinystatus.service
- tinystatus.timer
notify: systemd daemon-reload
- name: Flush handlers
meta: flush_handlers
- name: Création du répertoire de site web pour génération du fichier
file:
state: directory
path: "{{ tinystatus_webdir }}"
owner: "{{ tinystatus_webuser }}"
group: "{{ tinystatus_webgrp }}"
setype: httpd_sys_content_t
mode: u=rx,g=rxs,o=rx
- name: Création du fichier d'index avec les bonnes permissions
file:
path: "{{ tinystatus_webdir }}/{{ tinystatus_pagefile }}"
state: touch
owner: "{{ tinystatus_user }}"
group: "{{ tinystatus_grp }}"
setype: httpd_sys_content_t
mode: 0644
- name: Active et démarre tinystatus.timer
systemd:
name: tinystatus.timer
enabled: yes
state: started

3
templates/checks.csv.j2 Normal file
View file

@ -0,0 +1,3 @@
{% for check in tinystatus_checks %}
{{ check.type }}, {{ check.code }}, {{ check.name }}, {{ check.host }}
{% endfor %}

View file

@ -0,0 +1,3 @@
{% for incident in tinystatus_incidents %}
{{ incident }}
{% endfor %}

View file

@ -0,0 +1,9 @@
[Unit]
Description=tinystatus
Documentation={{ tinstatus_gitrepo }}
[Service]
Type=oneshot
User={{ tinystatus_user }}
ExecStart={{ tinystatus_bindir }}/tinystatus.sh
PrivateTmp=true

View file

@ -0,0 +1,3 @@
#!/bin/bash
# {{ ansible_managed }}
{{ tinystatus_bindir }}/tinystatus {{ tinystatus_configdir }}/checks.csv {{ tinystatus_configdir }}/incidents.txt > {{ tinystatus_webdir }}/{{ tinystatus_pagefile }}

View file

@ -0,0 +1,9 @@
[Unit]
Description=Run tinystatus
[Timer]
OnCalendar={{ tinystatus_Timer_OnCalendar }}
RandomizedDelaySec={{ tinystatus_RandomizedDelaySec }}
[Install]
WantedBy=timers.target