From aa8aca6a26a44eb6c7fceb22f50d93f19ed676f8 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Mon, 28 Dec 2020 13:53:19 +0100 Subject: [PATCH] Init statping role --- plays/monitoring.yml | 3 ++ roles/statping/handlers/main.yml | 10 ++++++ roles/statping/tasks/main.yml | 36 +++++++++++++++++++ .../systemd/system/statping.service.j2 | 17 +++++++++ .../templates/update-motd.d/05-service.j2 | 3 ++ 5 files changed, 69 insertions(+) create mode 100644 roles/statping/handlers/main.yml create mode 100644 roles/statping/tasks/main.yml create mode 100644 roles/statping/templates/systemd/system/statping.service.j2 create mode 100755 roles/statping/templates/update-motd.d/05-service.j2 diff --git a/plays/monitoring.yml b/plays/monitoring.yml index 3aa9960c..ca8fc85a 100755 --- a/plays/monitoring.yml +++ b/plays/monitoring.yml @@ -88,3 +88,6 @@ # Monitor logs with mtail #- hosts: thot.adm.crans.org # roles: ["mtail"] + +- hosts: sputnik.adm.crans.org + roles: ["statping"] diff --git a/roles/statping/handlers/main.yml b/roles/statping/handlers/main.yml new file mode 100644 index 00000000..c395b355 --- /dev/null +++ b/roles/statping/handlers/main.yml @@ -0,0 +1,10 @@ +--- +- name: Restart nginx + service: + name: nginx + state: restarted + +- name: Restart statping + service: + name: statping + state: restarted diff --git a/roles/statping/tasks/main.yml b/roles/statping/tasks/main.yml new file mode 100644 index 00000000..03578d70 --- /dev/null +++ b/roles/statping/tasks/main.yml @@ -0,0 +1,36 @@ +--- +- name: Install statping + unarchive: + src: https://github.com/statping/statping/releases/download/v0.90.74/statping-linux-amd64.tar.gz + dest: /usr/local/bin/ + remote_src: yes + +- name: Create statping user + user: + create_home: yes + home: /var/lib/statping + system: yes + state: present + password: "!" + update_password: always + name: statping + +- name: Install statping systemd unit + template: + src: "systemd/system/statping.service.j2" + dest: "/etc/systemd/system/statping.service" + mode: 0644 + notify: Restart statping + +- name: Load and activate statping systemd unit + systemd: + name: statping.service + daemon_reload: true + enabled: true + state: started + +- name: Indicate role in motd + template: + src: update-motd.d/05-service.j2 + dest: /etc/update-motd.d/05-statping + mode: 0755 diff --git a/roles/statping/templates/systemd/system/statping.service.j2 b/roles/statping/templates/systemd/system/statping.service.j2 new file mode 100644 index 00000000..0fc921ef --- /dev/null +++ b/roles/statping/templates/systemd/system/statping.service.j2 @@ -0,0 +1,17 @@ +{{ ansible_header | comment }} + +[Unit] +Description=Statping Server +After=network.target +After=systemd-user-sessions.service +After=network-online.target + +[Service] +Type=simple +User=statping +Restart=always +ExecStart=/usr/local/bin/statping +WorkingDirectory=/var/local/statping + +[Install] +WantedBy=multi-user.target diff --git a/roles/statping/templates/update-motd.d/05-service.j2 b/roles/statping/templates/update-motd.d/05-service.j2 new file mode 100755 index 00000000..6255aa81 --- /dev/null +++ b/roles/statping/templates/update-motd.d/05-service.j2 @@ -0,0 +1,3 @@ +#!/usr/bin/tail +14 +{{ ansible_header | comment }} +> Statping a été déployé sur cette machine. Voir /var/local/statping/.