aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-12-07 12:29:07 +0100
committerbinary <me@rgoncalves.se>2020-12-07 12:29:07 +0100
commit8168119817fb5952095f8757ad0d6f74a556b75d (patch)
tree4b4d705b62e67a6aed0566fb5b5dedc965ff992d
parentaa76b9a63e63cd2b88143390cf2c5fb63af61e06 (diff)
downloadinfrastructure-8168119817fb5952095f8757ad0d6f74a556b75d.tar.gz
Dynamic httpd configuration via include
-rw-r--r--roles/httpd/tasks/main.yml34
-rw-r--r--roles/httpd/templates/httpd.conf.j216
-rw-r--r--roles/stagit/files/httpd.conf2
-rw-r--r--roles/stagit/tasks/main.yml22
4 files changed, 66 insertions, 8 deletions
diff --git a/roles/httpd/tasks/main.yml b/roles/httpd/tasks/main.yml
new file mode 100644
index 0000000..4abf95a
--- /dev/null
+++ b/roles/httpd/tasks/main.yml
@@ -0,0 +1,34 @@
+
+# dns ~~ roles/dns/tasks/main.yml
+# ensure host is using unified dns
+
+---
+
+- name: ensure httpd.d directory exists
+ file:
+ path: /etc/httpd.d
+ state: directory
+ owner: "{{ user_root }}"
+ group: "{{ group_root }}"
+ mode: 0644
+
+- name: retrieve all configuration files
+ find:
+ path: /etc/httpd.d
+ patterns: "*.conf"
+ register: configurations
+
+- name: generate httpd configuration
+ template:
+ src: httpd.conf.j2
+ dest: /etc/httpd.conf
+ owner: "{{ user_root }}"
+ group: "{{ group_root }}"
+ mode: 0644
+
+- name: enable and restart httpd
+ service:
+ name: httpd
+ state: restarted
+ enabled: true
+
diff --git a/roles/httpd/templates/httpd.conf.j2 b/roles/httpd/templates/httpd.conf.j2
new file mode 100644
index 0000000..f437f41
--- /dev/null
+++ b/roles/httpd/templates/httpd.conf.j2
@@ -0,0 +1,16 @@
+
+# httpd.conf ~~ /etc/httpd.conf
+# 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
+}
+
+{% for file in configurations.files %}
+include "{{ file.path }}"
+{% endfor %}
diff --git a/roles/stagit/files/httpd.conf b/roles/stagit/files/httpd.conf
index ebf1c88..c91795e 100644
--- a/roles/stagit/files/httpd.conf
+++ b/roles/stagit/files/httpd.conf
@@ -3,7 +3,7 @@
# managed by Ansible
server "default" {
- listen on * port 80
+ listen on * port 1234
root "/htdocs/stagit"
location match "style.css" {
diff --git a/roles/stagit/tasks/main.yml b/roles/stagit/tasks/main.yml
index 1e7b67f..37b92e5 100644
--- a/roles/stagit/tasks/main.yml
+++ b/roles/stagit/tasks/main.yml
@@ -33,10 +33,13 @@
group: "{{ group_root }}"
mode: 0644
+- name: ensure httpd.d directory exists
+ file: path=/etc/httpd.d state=directory
+
- name: copy httpd configuration
copy:
src: httpd.conf
- dest: /etc/httpd.conf
+ dest: /etc/httpd.d/stagit.conf
owner: "{{ user_root }}"
group: "{{ group_root }}"
mode: 0644
@@ -49,18 +52,23 @@
group: "{{ group_root }}"
mode: 0644
-- name: ensure httpd is enabled and restarted
- service:
- name: httpd
- state: restarted
- enabled: true
-
- name: enable cron job for static-page generation
cron:
name: "Static git-page generation"
minute: "5"
job: "cd /var/www/htdocs/stagit && ./generate-static-git.sh"
+- name: enable gitdaemon
+ lineinfile:
+ path: /etc/rc.conf.local
+ regexp: "^gitdaemon_flags="
+ line: "gitdaemon_flags=--reuseaddr --base-path=/data/git"
+
+- name: start gitdaemon
+ service:
+ name: gitdaemon
+ state: restarted
+
- name: execute static-page generation script once
shell: ./generate-static-git.sh
args:
remember that computers suck.