aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2024-01-01 13:26:11 +0100
committerRomain Gonçalves <me@rgoncalves.se>2024-01-01 13:26:11 +0100
commite5a65b550c719f427e0bb46f2e3149092b9e6285 (patch)
treead5cbf5cac81b49e104ff0ffb5711e37e7f70285
parentd5175b4fb930f1ca48e514a4ab8080f050d4c6bc (diff)
downloadrules-e5a65b550c719f427e0bb46f2e3149092b9e6285.tar.gz
refactor(roles/httpd): merge httpd roles
-rw-r--r--roles/httpd/defaults/main.yml14
-rw-r--r--roles/httpd/meta/main.yml7
-rw-r--r--roles/httpd/tasks/main.yml26
-rw-r--r--roles/httpd/templates/httpd.conf.j217
-rw-r--r--roles/httpd_pre/defaults/main.yml8
-rw-r--r--roles/httpd_pre/tasks/main.yml24
-rw-r--r--roles/httpd_site_healthcheck/defaults/main.yml8
-rw-r--r--roles/httpd_site_healthcheck/meta/main.yml5
-rw-r--r--roles/httpd_site_healthcheck/tasks/main.yml25
-rw-r--r--roles/httpd_site_healthcheck/templates/httpd.conf.j26
-rw-r--r--roles/httpd_site_healthcheck/templates/index.html.j234
11 files changed, 43 insertions, 131 deletions
diff --git a/roles/httpd/defaults/main.yml b/roles/httpd/defaults/main.yml
index 3b0acd0..f5e0a43 100644
--- a/roles/httpd/defaults/main.yml
+++ b/roles/httpd/defaults/main.yml
@@ -2,7 +2,19 @@
httpd_configuration_file: /etc/httpd.conf
httpd_configuration_dir: /etc/httpd.d
-httpd_chroot: /var/www
+httpd_chroot_dir: /var/www
+httpd_passwords_dir: "{{ httpd_chroot_dir }}/htpasswd"
+httpd_sites_dir: "{{ httpd_chroot_dir }}/htdocs"
httpd_user: www
httpd_group: www
+
+httpd_supported_types:
+ - application/xml xml rss
+ - image/gif gif
+ - image/jpeg jpeg jpg
+ - image/png png
+ - image/svg+xml svg
+ - text/css css
+ - text/html html htm
+ - text/plain txt pgp pub
diff --git a/roles/httpd/meta/main.yml b/roles/httpd/meta/main.yml
deleted file mode 100644
index 161e3b8..0000000
--- a/roles/httpd/meta/main.yml
+++ /dev/null
@@ -1,7 +0,0 @@
----
-
-dependencies:
- - role: httpd_pre
- tags: dependency
- - role: httpd_site_healthcheck
- tags: dependency
diff --git a/roles/httpd/tasks/main.yml b/roles/httpd/tasks/main.yml
index f946044..584ae0b 100644
--- a/roles/httpd/tasks/main.yml
+++ b/roles/httpd/tasks/main.yml
@@ -1,10 +1,34 @@
---
+- name: create httpd directory
+ ansible.builtin.file:
+ path: "{{ httpd_configuration_dir }}"
+ state: directory
+ owner: 0
+ group: 0
+ mode: "0644"
+
+- name: create passwords directory
+ ansible.builtin.file:
+ path: "{{ httpd_passwords_dir }}"
+ state: directory
+ owner: "{{ httpd_user }}"
+ group: "{{ httpd_group }}"
+ mode: "0700"
+
+- name: create sites directory
+ ansible.builtin.file:
+ path: "{{ httpd_sites_dir }}"
+ state: directory
+ owner: 0
+ group: 0
+ mode: "0755"
+
- name: retrieve all configuration files
ansible.builtin.find:
path: "{{ httpd_configuration_dir }}"
patterns: "*.conf"
- register: configuration_files
+ register: httpd_configuration_files
- name: generate httpd configuration
ansible.builtin.template:
diff --git a/roles/httpd/templates/httpd.conf.j2 b/roles/httpd/templates/httpd.conf.j2
index 6285d70..49e928d 100644
--- a/roles/httpd/templates/httpd.conf.j2
+++ b/roles/httpd/templates/httpd.conf.j2
@@ -1,18 +1,12 @@
# managed by Ansible
types {
- text/css css
- text/html html htm
- text/plain txt pgp pub
- image/gif gif
- image/jpeg jpeg jpg
- image/png png
- image/svg+xml svg
- application/xml xml rss
+{% for type in httpd_supported_types %}
+ {{ type }}
+{% endfor %}
}
-{% if inventory_hostname == __global_domain_controller %}
-server "default" {
+server "acme" {
listen on localhost port 8888
location "/.well-known/acme-challenge/*" {
@@ -24,8 +18,7 @@ server "default" {
block return 302 "https://$HTTP_HOST$REQUEST_URI"
}
}
-{% endif %}
-{% for file in configuration_files.files %}
+{% for file in httpd_configuration_files.files %}
include "{{ file.path }}"
{% endfor %}
diff --git a/roles/httpd_pre/defaults/main.yml b/roles/httpd_pre/defaults/main.yml
deleted file mode 100644
index 3b0acd0..0000000
--- a/roles/httpd_pre/defaults/main.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-
-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_pre/tasks/main.yml b/roles/httpd_pre/tasks/main.yml
deleted file mode 100644
index acc6673..0000000
--- a/roles/httpd_pre/tasks/main.yml
+++ /dev/null
@@ -1,24 +0,0 @@
----
-
-- name: create httpd directory
- ansible.builtin.file:
- path: /etc/httpd.d
- state: directory
- owner: 0
- group: 0
- mode: "0644"
-
-- name: create htpasswd directory
- ansible.builtin.file:
- path: /var/www/htpasswd
- state: directory
- owner: "www"
- group: "www"
- mode: "0700"
-
-- name: mount nfs in chroot
- ansible.builtin.include_role:
- name: nfsclient
- vars:
- nfsclient_dir: "{{ httpd_chroot }}/data"
- when: httpd_use_nfs
diff --git a/roles/httpd_site_healthcheck/defaults/main.yml b/roles/httpd_site_healthcheck/defaults/main.yml
deleted file mode 100644
index 3b0acd0..0000000
--- a/roles/httpd_site_healthcheck/defaults/main.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-
-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_site_healthcheck/meta/main.yml b/roles/httpd_site_healthcheck/meta/main.yml
deleted file mode 100644
index dd93239..0000000
--- a/roles/httpd_site_healthcheck/meta/main.yml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-
-dependencies:
- - role: httpd_pre
- tags: dependency
diff --git a/roles/httpd_site_healthcheck/tasks/main.yml b/roles/httpd_site_healthcheck/tasks/main.yml
deleted file mode 100644
index 7cb2edb..0000000
--- a/roles/httpd_site_healthcheck/tasks/main.yml
+++ /dev/null
@@ -1,25 +0,0 @@
----
-
-- name: create httpd healthcheck directory
- ansible.builtin.file:
- path: "{{ httpd_chroot }}/htdocs/healthcheck"
- owner: "{{ httpd_user }}"
- group: "{{ httpd_group }}"
- mode: "0550"
- state: directory
-
-- name: generate generate httpd healthcheck html index
- ansible.builtin.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
- ansible.builtin.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
deleted file mode 100644
index 17ffd04..0000000
--- a/roles/httpd_site_healthcheck/templates/httpd.conf.j2
+++ /dev/null
@@ -1,6 +0,0 @@
-# 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
deleted file mode 100644
index c52ff41..0000000
--- a/roles/httpd_site_healthcheck/templates/index.html.j2
+++ /dev/null
@@ -1,34 +0,0 @@
-<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.