diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-04-24 12:57:57 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-04-24 12:57:57 +0300 |
commit | 8d7be2a4659f20af0386048b2444f6d0adc59c41 (patch) | |
tree | d5e8664ad20a66054529f680b661f64851b060c3 /roles/apache_server | |
parent | bc0d7897d1f4a88d5d60b9460a3fd52a3fc196bc (diff) | |
download | debian-ansible-8d7be2a4659f20af0386048b2444f6d0adc59c41.tar.gz |
Rename roles to be more specific
Suggested by Ivan Dolgov.
Diffstat (limited to 'roles/apache_server')
-rw-r--r-- | roles/apache_server/README | 4 | ||||
-rw-r--r-- | roles/apache_server/defaults/main.yml | 17 | ||||
-rw-r--r-- | roles/apache_server/handlers/main.yml | 4 | ||||
-rw-r--r-- | roles/apache_server/tasks/main.yml | 38 | ||||
-rw-r--r-- | roles/apache_server/templates/virtualhost.conf.tmpl | 14 |
5 files changed, 77 insertions, 0 deletions
diff --git a/roles/apache_server/README b/roles/apache_server/README new file mode 100644 index 0000000..61ab80d --- /dev/null +++ b/roles/apache_server/README @@ -0,0 +1,4 @@ +This role provides a web server for static sites using Apache. More +dynamic sites can be built on top by other roles by enablind Apache +modules and adding sites with suitable configs. + diff --git a/roles/apache_server/defaults/main.yml b/roles/apache_server/defaults/main.yml new file mode 100644 index 0000000..cfa797c --- /dev/null +++ b/roles/apache_server/defaults/main.yml @@ -0,0 +1,17 @@ +# List of domains names for static sites served by this host. This +# should be a list of dicts with the following fields: +# +# domain: the domain name +# alias: another domain name that is also for this site +# owner: local Unix user of site owner +# ownermail: email address for the site owner +# +# Example: +# +# static_sites: +# - domain: liw.fi +# alias: www.liw.fi +# owner: liw +# ownermail: liw@liw.fi + +static_sites: [] diff --git a/roles/apache_server/handlers/main.yml b/roles/apache_server/handlers/main.yml new file mode 100644 index 0000000..24f6f27 --- /dev/null +++ b/roles/apache_server/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart apache + systemd: + name: apache2 + state: restarted
\ No newline at end of file diff --git a/roles/apache_server/tasks/main.yml b/roles/apache_server/tasks/main.yml new file mode 100644 index 0000000..8a14b35 --- /dev/null +++ b/roles/apache_server/tasks/main.yml @@ -0,0 +1,38 @@ +- name: install rsync (so one can publish files via server) + apt: name=rsync + +- name: install apache2 + apt: name=apache2 + +- name: create dirs for static site contents + file: + state: directory + path: "/srv/http/{{ item.domain }}" + owner: "{{ item.owner }}" + group: "{{ item.owner }}" + mode: 0755 + with_items: "{{ static_sites }}" + +- name: create log dirs for websites + file: + state: directory + path: "/var/log/apache2/{{ item.domain }}" + owner: www-data + group: www-data + mode: 0755 + with_items: "{{ static_sites }}" + +- name: configure apache to serve static sites + template: + src: virtualhost.conf.tmpl + dest: "/etc/apache2/sites-available/{{ item.domain }}.conf" + owner: root + group: root + mode: 0644 + with_items: "{{ static_sites }}" + +- name: enable apache sites + shell: a2ensite "{{ item.domain }}" + with_items: "{{ static_sites }}" + notify: + - restart apache diff --git a/roles/apache_server/templates/virtualhost.conf.tmpl b/roles/apache_server/templates/virtualhost.conf.tmpl new file mode 100644 index 0000000..6afdd41 --- /dev/null +++ b/roles/apache_server/templates/virtualhost.conf.tmpl @@ -0,0 +1,14 @@ +<VirtualHost *:80> + ServerName {{ item.domain }} +{% if item.alias is defined %} + ServerAlias {{ item.alias }} +{% endif %} + ServerAdmin {{ item.ownermail }} + DocumentRoot /srv/http/{{ item.domain }} + ErrorLog /var/log/apache2/{{ item.domain }}/error.log + CustomLog /var/log/apache2/{{ item.domain }}/access.log combined + <Directory /srv/http/{{ item.domain }}> + Options +SymlinksIfOwnerMatch +Indexes + Require all granted + </Directory> +</VirtualHost> |