diff --git a/roles/nginx/files/etc/nginx/include/listing.conf b/roles/nginx/files/etc/nginx/include/listing.conf new file mode 100644 index 0000000..d161622 --- /dev/null +++ b/roles/nginx/files/etc/nginx/include/listing.conf @@ -0,0 +1,5 @@ +location / { + autoindex on; + autoindex_exact_size on; + autoindex_localtime off; +} diff --git a/roles/website/ffnord/handlers/main.yml b/roles/website/ffnord/handlers/main.yml new file mode 100644 index 0000000..857d50c --- /dev/null +++ b/roles/website/ffnord/handlers/main.yml @@ -0,0 +1,2 @@ +--- +- include: ../../includes/base-static/handlers/main.yml diff --git a/roles/website/ffnord/main.yml b/roles/website/ffnord/main.yml deleted file mode 100644 index da44096..0000000 --- a/roles/website/ffnord/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -handlers: - - include: ../../nginx/handlers/main.yml - diff --git a/roles/website/ffnord/meta/main.yml b/roles/website/ffnord/meta/main.yml index e3d1763..f6688f0 100644 --- a/roles/website/ffnord/meta/main.yml +++ b/roles/website/ffnord/meta/main.yml @@ -1,3 +1,4 @@ --- dependencies: - - { role: nginx } + - role: nginx + diff --git a/roles/website/ffnord/tasks/main.yml b/roles/website/ffnord/tasks/main.yml index 4abaf44..d6558a2 100644 --- a/roles/website/ffnord/tasks/main.yml +++ b/roles/website/ffnord/tasks/main.yml @@ -1,30 +1,13 @@ --- -- name: configure ffnord.net site - copy: > - src=etc/nginx/sites-available/ffnord.net - dest=/etc/nginx/sites-available/ffnord.net - owner=root - group=root - mode=0644 - notify: reload nginx config - tags: - - nginx - - website - - ffnord - -- name: enable ffnord.net site - file: > - src=/etc/nginx/sites-available/ffnord.net - dest=/etc/nginx/sites-enabled/ffnord.net - owner=root - group=root - mode=0644 - state=link - notify: reload nginx config - tags: - - nginx - - website - - ffnord +- include: ../../includes/base-static/tasks/main.yml + vars: + site: ffnord.net + domains: + - ffnord.net + - www.ffnord.net + - nord.freifunk.net + document_root: /var/www/ffnord.net/site + listing: false - name: clone ffnord.net repository git: repo=https://github.com/ffnord/ffnord.net.git dest=/var/www/ffnord.net diff --git a/roles/website/includes/base-static/handlers/main.yml b/roles/website/includes/base-static/handlers/main.yml new file mode 100644 index 0000000..40a0168 --- /dev/null +++ b/roles/website/includes/base-static/handlers/main.yml @@ -0,0 +1,2 @@ +--- +- include: ../../../../nginx/handlers/main.yml diff --git a/roles/website/includes/base-static/tasks/main.yml b/roles/website/includes/base-static/tasks/main.yml new file mode 100644 index 0000000..c5499ce --- /dev/null +++ b/roles/website/includes/base-static/tasks/main.yml @@ -0,0 +1,28 @@ +--- +- name: configure {{ site }} site + template: > + src=site.j2 + dest=/etc/nginx/sites-available/{{ site }} + owner=root + group=root + mode=0644 + notify: reload nginx config + tags: + - nginx + - website + - "{{ site }}" + +- name: enable {{ site }} site + file: > + src=/etc/nginx/sites-available/{{ site }} + dest=/etc/nginx/sites-enabled/{{ site }} + owner=root + group=root + mode=0644 + state=link + notify: reload nginx config + tags: + - nginx + - website + - "{{ site }}" + diff --git a/roles/website/ffnord/files/etc/nginx/sites-available/ffnord.net b/roles/website/includes/base-static/templates/site.j2 similarity index 55% rename from roles/website/ffnord/files/etc/nginx/sites-available/ffnord.net rename to roles/website/includes/base-static/templates/site.j2 index 69793f2..adc6019 100644 --- a/roles/website/ffnord/files/etc/nginx/sites-available/ffnord.net +++ b/roles/website/includes/base-static/templates/site.j2 @@ -3,11 +3,15 @@ server { include /etc/nginx/include/no_dotfiles.conf; include /etc/nginx/include/no_symlinks.conf; + {% if listing %} + include /etc/nginx/include/listing.conf; + {% endif %} + listen 80; listen [::]:80; - server_name ffnord.net www.ffnord.net nord.freifunk.net; + server_name {{ domains | join(" ") }}; - root /var/www/ffnord.net/site; + root {{ document_root }}; } diff --git a/roles/website/media/handlers/main.yml b/roles/website/media/handlers/main.yml new file mode 100644 index 0000000..857d50c --- /dev/null +++ b/roles/website/media/handlers/main.yml @@ -0,0 +1,2 @@ +--- +- include: ../../includes/base-static/handlers/main.yml diff --git a/roles/website/media/meta/main.yml b/roles/website/media/meta/main.yml new file mode 100644 index 0000000..f6688f0 --- /dev/null +++ b/roles/website/media/meta/main.yml @@ -0,0 +1,4 @@ +--- +dependencies: + - role: nginx + diff --git a/roles/website/media/tasks/main.yml b/roles/website/media/tasks/main.yml new file mode 100644 index 0000000..1a46060 --- /dev/null +++ b/roles/website/media/tasks/main.yml @@ -0,0 +1,16 @@ +--- +- include: ../../includes/base-static/tasks/main.yml + vars: + site: media_ffhh + domains: + - media.services.ffhh + - media.hamburg.freifunk.net + document_root: /var/www/media + listing: true + +- name: create media root + file: path=/var/www/media state=directory owner=www-data group=www-data mode=0755 + tags: + - nginx + - website + - media_ffhh diff --git a/services.yml b/services.yml index 78ebf29..a9d547b 100644 --- a/services.yml +++ b/services.yml @@ -3,4 +3,5 @@ roles: - ntp-server - website/ffnord + - website/media