aboutsummaryrefslogtreecommitdiff
path: root/roles/nginx_docker/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/nginx_docker/tasks')
-rw-r--r--roles/nginx_docker/tasks/main.yaml43
1 files changed, 43 insertions, 0 deletions
diff --git a/roles/nginx_docker/tasks/main.yaml b/roles/nginx_docker/tasks/main.yaml
new file mode 100644
index 0000000..bda276e
--- /dev/null
+++ b/roles/nginx_docker/tasks/main.yaml
@@ -0,0 +1,43 @@
+---
+
+- name: 'Ensure conf dir exists'
+ file:
+ path: '{{ item }}'
+ state: 'directory'
+ mode: '755'
+ loop:
+ - '{{ nginx_conf_root }}'
+ - '{{ nginx_static_html_root }}'
+ - '{{ nginx_certs_root }}'
+
+- name: 'Copy the http nginx.conf files'
+ template:
+ src: 'http.nginx.conf.j2'
+ dest: '{{ nginx_conf_root }}/{{ item }}.conf'
+ mode: '644'
+ loop: '{{ nginx_website_domains }}'
+
+- name: 'Copy the http nginx.conf for apps'
+ template:
+ src: 'app.nginx.conf.j2'
+ dest: '{{ nginx_conf_root }}/{{ item.app }}.conf'
+ mode: '644'
+ when: 'item.conf.access_domain is defined'
+ loop: '{{ nginx_apps_confs }}'
+
+- name: 'Start the Nginx container'
+ community.docker.docker_container:
+ name: 'nginx'
+ image: 'nginx:alpine'
+ pull: true
+ state: 'started'
+ recreate: false
+ volumes:
+ # configs
+ - '{{ nginx_conf_root }}:/etc/nginx/conf.d/:ro'
+ # static pages html
+ - '{{ nginx_static_html_root }}:/var/www/:ro'
+ # ssl certs
+ - '{{ nginx_certs_root }}:/etc/letsencrypt/:ro'
+ network_mode: 'host'
+ restart_policy: 'unless-stopped'