summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Porte <microjoe@microjoe.org>2020-05-09 16:36:51 +0200
committerRomain Porte <microjoe@microjoe.org>2020-05-09 16:36:51 +0200
commitefabcac0919f188ee1b685ca09dd6a2a318a7362 (patch)
treee6635a5d9277e28a854287be5bbd51922c30d67e
parent000ccd0f2104774884463749d9816de3d010d528 (diff)
downloadMicroJoe.nginx-staticwebsite-master.tar.gz
MicroJoe.nginx-staticwebsite-master.zip
allow multiple domains to optimize setup timeHEADmaster
-rw-r--r--tasks/create-website.yml14
-rw-r--r--tasks/main.yml24
-rw-r--r--vars/main.yml3
3 files changed, 24 insertions, 17 deletions
diff --git a/tasks/create-website.yml b/tasks/create-website.yml
new file mode 100644
index 0000000..6f8c81f
--- /dev/null
+++ b/tasks/create-website.yml
@@ -0,0 +1,14 @@
+- name: Make sure root directory {{ nginx_root }} exists
+ file:
+ path: "{{ nginx_root }}"
+ state: directory
+ owner: "{{ nginx_upload_user }}"
+ group: "{{ nginx_upload_group }}"
+
+- name: Install nginx configuration file {{ nginx_filename }}
+ template:
+ src: templates/nginx.j2
+ dest: /etc/nginx/sites-available/{{ nginx_filename }}
+ owner: root
+ group: root
+ notify: restart nginx
diff --git a/tasks/main.yml b/tasks/main.yml
index 4ffde51..dac4bd6 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -20,17 +20,13 @@
owner: "{{ nginx_upload_user }}"
group: "{{ nginx_upload_group }}"
-- name: Make sure root directory {{ nginx_root }} exists
- file:
- path: "{{ nginx_root }}"
- state: directory
- owner: "{{ nginx_upload_user }}"
- group: "{{ nginx_upload_group }}"
-
-- name: Install nginx configuration file {{ nginx_filename }}
- template:
- src: templates/nginx.j2
- dest: /etc/nginx/sites-available/{{ nginx_filename }}
- owner: root
- group: root
- notify: restart nginx
+- include_tasks: create-website.yml
+ vars:
+ nginx_domain: "{{ nginx_item.domain }}"
+ nginx_root: "/var/www/{{ nginx_item.domain }}/"
+ nginx_filename: "static-{{ nginx_item.domain }}"
+ nginx_autoindex: "{{ nginx_item.autoindex | default(None) }}"
+ nginx_auth_file: "{{ nginx_item.auth_file | default(None) }}"
+ with_items: "{{ nginx_domains }}"
+ loop_control:
+ loop_var: nginx_item
diff --git a/vars/main.yml b/vars/main.yml
index 7d4fb5f..dbc3a42 100644
--- a/vars/main.yml
+++ b/vars/main.yml
@@ -1,5 +1,2 @@
---
# vars file for MicroJoe.staticwebsite
-
-nginx_root: "/var/www/{{ nginx_domain }}/"
-nginx_filename: "static-{{ nginx_domain }}"