aboutsummaryrefslogtreecommitdiffstats
path: root/roles/obsd_httpd
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2026-10-03 11:41:33 -0700
committerEugene Triguba <hello@eugenetriguba.com>2026-10-11 18:36:45 -0700
commit024ae3365ffa40b5d0b117577c552587b258ca7a (patch)
treea2907f5a9018009e55b0d1690c3210844b74af30 /roles/obsd_httpd
downloadsite-configs-024ae3365ffa40b5d0b117577c552587b258ca7a.zip
Initial Commit
Diffstat (limited to 'roles/obsd_httpd')
-rw-r--r--roles/obsd_httpd/defaults/main.yml1
-rw-r--r--roles/obsd_httpd/handlers/main.yml2
-rw-r--r--roles/obsd_httpd/tasks/main.yml55
-rw-r--r--roles/obsd_httpd/templates/httpd.conf.j25
4 files changed, 63 insertions, 0 deletions
diff --git a/roles/obsd_httpd/defaults/main.yml b/roles/obsd_httpd/defaults/main.yml
new file mode 100644
index 0000000..48406cb
--- /dev/null
+++ b/roles/obsd_httpd/defaults/main.yml
@@ -0,0 +1 @@
+httpd_conf_d: /etc/httpd.d
diff --git a/roles/obsd_httpd/handlers/main.yml b/roles/obsd_httpd/handlers/main.yml
new file mode 100644
index 0000000..3af955f
--- /dev/null
+++ b/roles/obsd_httpd/handlers/main.yml
@@ -0,0 +1,2 @@
+- name: restart httpd
+ ansible.builtin.command: rcctl restart httpd
diff --git a/roles/obsd_httpd/tasks/main.yml b/roles/obsd_httpd/tasks/main.yml
new file mode 100644
index 0000000..36ff9fb
--- /dev/null
+++ b/roles/obsd_httpd/tasks/main.yml
@@ -0,0 +1,55 @@
+- name: Create httpd conf include directory
+ ansible.builtin.file:
+ path: "{{ httpd_conf_d }}"
+ state: directory
+ owner: root
+ group: wheel
+ mode: "0755"
+
+- name: Deploy httpd.conf
+ ansible.builtin.template:
+ src: httpd.conf.j2
+ dest: /etc/httpd.conf
+ owner: root
+ group: wheel
+ mode: "0600"
+ notify: restart httpd
+
+- name: Ensure all registered httpd fragment files exist
+ # If they don't exist, httpd validate will fail. So we want to create them,
+ # even if empty for now.
+ ansible.builtin.copy:
+ content: ""
+ dest: "{{ httpd_conf_d }}/{{ item }}"
+ force: false # If it already exists, don't overwrite it.
+ owner: root
+ group: wheel
+ mode: "0644"
+ loop: "{{ httpd_fragments }}"
+
+- name: Validate httpd config
+ ansible.builtin.command: httpd -n
+ changed_when: false
+
+- name: Enable httpd and slowcgi
+ ansible.builtin.command: "rcctl enable {{ item }}"
+ args:
+ creates: "/etc/rc.conf.d/{{ item }}"
+ loop:
+ - httpd
+ - slowcgi
+ changed_when: true
+
+- name: Check service status
+ ansible.builtin.command: rcctl check {{ item }}
+ register: httpd_check
+ changed_when: false
+ failed_when: false # rc 1 exit code means "not running"
+ loop:
+ - httpd
+ - slowcgi
+
+- name: Start services that are not running
+ ansible.builtin.command: rcctl start {{ item.item }}
+ loop: "{{ httpd_check.results }}"
+ when: item.rc != 0
diff --git a/roles/obsd_httpd/templates/httpd.conf.j2 b/roles/obsd_httpd/templates/httpd.conf.j2
new file mode 100644
index 0000000..beec99c
--- /dev/null
+++ b/roles/obsd_httpd/templates/httpd.conf.j2
@@ -0,0 +1,5 @@
+types { include "/usr/share/misc/mime.types" }
+
+{% for fragment in httpd_fragments %}
+include "{{ httpd_conf_d }}/{{ fragment }}"
+{% endfor %}