diff --git a/defaults/main.yml b/defaults/main.yml index cc23928..66a5d7a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -11,3 +11,4 @@ common__nginx__upstreams: [] common__nginx__sites: [] common__apache__remove_default: true +common__apache__sites: [] diff --git a/tasks/apache.yml b/tasks/apache.yml index 55dc304..8035edf 100644 --- a/tasks/apache.yml +++ b/tasks/apache.yml @@ -28,3 +28,20 @@ path: '{{ common__apache__enabled_dir }}/000-default.conf' when: common__apache__remove_default|bool notify: common | Restart Apache + +- name: Add Apache sites + template: + src: 'templates/apache/{{ item.type }}.conf' + dest: '{{ common__apache__available_dir }}/{{ item.domain }}.conf' + mode: 'u=rw,g=r,o=r' + owner: root + group: root + with_items: '{{ common__apache__sites }}' + notify: common | Restart Apache + +- name: Enable Apache sites + command: '/usr/sbin/a2ensite "{{ item.domain }}.conf"' + register: common__apache__enable_apache_sites_result + changed_when: "common__apache__enable_apache_sites_result.stdout is search('Enabling site {{ item.domain }}')" + with_items: '{{ common__apache__sites }}' + notify: common | Restart Apache diff --git a/templates/apache/origin.conf b/templates/apache/origin.conf new file mode 100644 index 0000000..33b1712 --- /dev/null +++ b/templates/apache/origin.conf @@ -0,0 +1,24 @@ +NameVirtualHost *:80 + + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + ServerName {{ item.domain }} + + Redirect permanent / https://wiki.crypto-libertarian.com + + + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + + ServerName {{ item.domain }} + + DocumentRoot {{ item.root }} + + SSLEngine on + SSLCertificateFile {{ item.cert }} + SSLCertificateKeyFile {{ item.key }} + SSLCertificateChainFile {{ item.chain }} +