Add and enable Apache sites

This commit is contained in:
Alex Kotov 2020-01-21 16:48:55 +05:00
parent 7992fcc291
commit 87bc4dd4f5
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 42 additions and 0 deletions

View File

@ -11,3 +11,4 @@ common__nginx__upstreams: []
common__nginx__sites: []
common__apache__remove_default: true
common__apache__sites: []

View File

@ -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

View File

@ -0,0 +1,24 @@
NameVirtualHost *:80
<VirtualHost *:80>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName {{ item.domain }}
Redirect permanent / https://wiki.crypto-libertarian.com
</VirtualHost>
<VirtualHost _default_:443>
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 }}
</VirtualHost>