diff options
Diffstat (limited to 'roles/httpd')
-rw-r--r-- | roles/httpd/defaults/main.yml | 11 | ||||
-rw-r--r-- | roles/httpd/tasks/main.yml | 32 | ||||
-rw-r--r-- | roles/httpd/templates/httpd.conf.j2 | 22 |
3 files changed, 28 insertions, 37 deletions
diff --git a/roles/httpd/defaults/main.yml b/roles/httpd/defaults/main.yml index f5e0a43..c0f92ed 100644 --- a/roles/httpd/defaults/main.yml +++ b/roles/httpd/defaults/main.yml @@ -1,15 +1,6 @@ --- -httpd_configuration_file: /etc/httpd.conf -httpd_configuration_dir: /etc/httpd.d -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: +httpd__supported_types: - application/xml xml rss - image/gif gif - image/jpeg jpeg jpg diff --git a/roles/httpd/tasks/main.yml b/roles/httpd/tasks/main.yml index 584ae0b..194f198 100644 --- a/roles/httpd/tasks/main.yml +++ b/roles/httpd/tasks/main.yml @@ -1,39 +1,25 @@ --- -- name: create httpd directory +- name: create static sites directories ansible.builtin.file: - path: "{{ httpd_configuration_dir }}" + path: "{{ httpd_pre__sites_dir }}/{{ item.domain }}" 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 + owner: "{{ httpd_pre__user }}" + group: "{{ httpd_pre__group }}" mode: "0755" + loop: "{{ httpd__rules }}" + when: item.extra.type is defined and item.extra.type == "static" - name: retrieve all configuration files ansible.builtin.find: - path: "{{ httpd_configuration_dir }}" + path: "{{ httpd_pre__configuration_dir }}" patterns: "*.conf" - register: httpd_configuration_files + register: httpd__configuration_files - name: generate httpd configuration ansible.builtin.template: src: httpd.conf.j2 - dest: "{{ httpd_configuration_file }}" + dest: "{{ httpd_pre__configuration_file }}" owner: 0 group: 0 mode: "0644" diff --git a/roles/httpd/templates/httpd.conf.j2 b/roles/httpd/templates/httpd.conf.j2 index 49e928d..9225244 100644 --- a/roles/httpd/templates/httpd.conf.j2 +++ b/roles/httpd/templates/httpd.conf.j2 @@ -1,24 +1,38 @@ # managed by Ansible types { -{% for type in httpd_supported_types %} +{% for type in httpd__supported_types %} {{ type }} {% endfor %} } -server "acme" { - listen on localhost port 8888 +server "default" { + listen on * port 8888 + log style {{ httpd__log_format }} + # acme tls challenge location "/.well-known/acme-challenge/*" { root "/acme" request strip 2 } + # redirection location * { block return 302 "https://$HTTP_HOST$REQUEST_URI" } } -{% for file in httpd_configuration_files.files %} +{% for item in httpd__rules %} +{% if item.extra.type is defined and item.extra.type == "static" %} +server "{{ item.domain }}" { + listen on localhost port {{ item.port }} + log style {{ httpd__log_format }} + root "{{ httpd_pre__chroot_sites_dir }}/{{ item.domain }}" +} + +{% endif %} +{% endfor %} + +{% for file in httpd__configuration_files.files %} include "{{ file.path }}" {% endfor %} |