aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2021-12-21 17:14:36 +0000
committerRomain Gonçalves <me@rgoncalves.se>2021-12-21 17:14:36 +0000
commit1db6aa5d8167b997924e4b78fdf1c6b8640db8fd (patch)
treed735e40462af7b585d0aef858b59018fe5addde3
parent3b046f2a5fdd2a0f02c171fb63d8328159d671ae (diff)
downloadrules-1db6aa5d8167b997924e4b78fdf1c6b8640db8fd.tar.gz
roles/httpd: Add healthcheck subrole
-rw-r--r--roles/httpd/defaults/main.yml3
-rw-r--r--roles/httpd/meta/main.yml2
l---------roles/httpd_site_healthcheck/defaults/main.yml1
-rw-r--r--roles/httpd_site_healthcheck/meta/main.yml3
-rw-r--r--roles/httpd_site_healthcheck/tasks/main.yml23
-rw-r--r--roles/httpd_site_healthcheck/templates/httpd.conf.j26
-rw-r--r--roles/httpd_site_healthcheck/templates/index.html.j234
7 files changed, 72 insertions, 0 deletions
diff --git a/roles/httpd/defaults/main.yml b/roles/httpd/defaults/main.yml
index e09e3cd..ce189c2 100644
--- a/roles/httpd/defaults/main.yml
+++ b/roles/httpd/defaults/main.yml
@@ -1,3 +1,6 @@
httpd_configuration_file: /etc/httpd.conf
httpd_configuration_dir: /etc/httpd.d
httpd_chroot: /var/www
+
+httpd_user: www
+httpd_group: www
diff --git a/roles/httpd/meta/main.yml b/roles/httpd/meta/main.yml
index 6b163d1..20728a9 100644
--- a/roles/httpd/meta/main.yml
+++ b/roles/httpd/meta/main.yml
@@ -1,3 +1,5 @@
dependencies:
- role: httpd_pre
tags: dependency
+ - role: httpd_site_healthcheck
+ tags: dependency
diff --git a/roles/httpd_site_healthcheck/defaults/main.yml b/roles/httpd_site_healthcheck/defaults/main.yml
new file mode 120000
index 0000000..52d65d9
--- /dev/null
+++ b/roles/httpd_site_healthcheck/defaults/main.yml
@@ -0,0 +1 @@
+../../httpd/defaults/main.yml \ No newline at end of file
diff --git a/roles/httpd_site_healthcheck/meta/main.yml b/roles/httpd_site_healthcheck/meta/main.yml
new file mode 100644
index 0000000..6b163d1
--- /dev/null
+++ b/roles/httpd_site_healthcheck/meta/main.yml
@@ -0,0 +1,3 @@
+dependencies:
+ - role: httpd_pre
+ tags: dependency
diff --git a/roles/httpd_site_healthcheck/tasks/main.yml b/roles/httpd_site_healthcheck/tasks/main.yml
new file mode 100644
index 0000000..10cd3c8
--- /dev/null
+++ b/roles/httpd_site_healthcheck/tasks/main.yml
@@ -0,0 +1,23 @@
+- name: create httpd healthcheck directory
+ file:
+ path: "{{ httpd_chroot }}/htdocs/healthcheck"
+ owner: "{{ httpd_user }}"
+ group: "{{ httpd_group }}"
+ mode: 0550
+ state: directory
+
+- name: generate generate httpd healthcheck html index
+ template:
+ src: index.html.j2
+ dest: "{{ httpd_chroot }}/htdocs/healthcheck/index.html"
+ owner: "{{ httpd_user }}"
+ group: "{{ httpd_group }}"
+ mode: 0440
+
+- name: generate httpd healthcheck configuration
+ template:
+ src: httpd.conf.j2
+ dest: "{{ httpd_configuration_dir }}/healthcheck.conf"
+ owner: 0
+ group: 0
+ mode: 0644
diff --git a/roles/httpd_site_healthcheck/templates/httpd.conf.j2 b/roles/httpd_site_healthcheck/templates/httpd.conf.j2
new file mode 100644
index 0000000..17ffd04
--- /dev/null
+++ b/roles/httpd_site_healthcheck/templates/httpd.conf.j2
@@ -0,0 +1,6 @@
+# managed by Ansible
+
+server "healthcheck" {
+ listen on * port 8000
+ root "/htdocs/healthcheck"
+}
diff --git a/roles/httpd_site_healthcheck/templates/index.html.j2 b/roles/httpd_site_healthcheck/templates/index.html.j2
new file mode 100644
index 0000000..c52ff41
--- /dev/null
+++ b/roles/httpd_site_healthcheck/templates/index.html.j2
@@ -0,0 +1,34 @@
+<html>
+<head>
+<meta charset="utf-8">
+<title>{{ inventory_hostname }} - healtcheck</title>
+<style>
+body {
+ background-color: white;
+ color: black;
+ font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif;
+}
+
+hr {
+ border: 0;
+ border-bottom: 1px dashed;
+}
+
+@media (prefers-color-scheme: dark) {
+ body {
+ background-color: #1E1F21;
+ color: #EEEFF1;
+ }
+
+ a {
+ color: #BAD7FF;
+ }
+}
+</style>
+</head>
+<body>
+<h1>{{ inventory_hostname }} - healtcheck</h1>
+<hr>
+<blockquote>Thank you for using {{ inventory_hostname }}.</blockquote>
+</body>
+</html>
remember that computers suck.