aboutsummaryrefslogtreecommitdiff
path: root/roles/nginx/tasks/main.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/nginx/tasks/main.yaml')
-rw-r--r--roles/nginx/tasks/main.yaml67
1 files changed, 67 insertions, 0 deletions
diff --git a/roles/nginx/tasks/main.yaml b/roles/nginx/tasks/main.yaml
new file mode 100644
index 0000000..91fd8a5
--- /dev/null
+++ b/roles/nginx/tasks/main.yaml
@@ -0,0 +1,67 @@
+# References
+# https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-debian-10
+
+---
+
+- name: 'Install nginx'
+ apt:
+ name:
+ - 'nginx'
+ state: 'present'
+ update_cache: true
+ notify:
+ - 'nginx_restart'
+
+- name: 'Copy the http nginx.conf files'
+ template:
+ src: 'http.nginx.conf.j2'
+ dest: '/etc/nginx/sites-available/{{ item }}'
+ mode: '644'
+ loop:
+ - 'default'
+ - 'kumardamani.xyz'
+ - 'amayastuff.com'
+ register: '_config_copy'
+ notify:
+ - 'nginx_restart'
+
+- name: 'Remove the old symbolic link'
+ file:
+ path: '/etc/nginx/sites-enabled/{{ item }}'
+ state: 'absent'
+ loop: '{{ nginx_website_domains }}'
+
+- name: 'Create a http symbolic link'
+ file:
+ src: '/etc/nginx/sites-available/{{ item }}'
+ dest: '/etc/nginx/sites-enabled/{{ item }}'
+ state: 'link'
+ loop: '{{ nginx_website_domains }}'
+
+- name: 'Check nginx config' # noqa no-changed-when
+ command: 'nginx -t'
+
+- name: 'Copy the http nginx.conf for apps'
+ template:
+ src: 'app.nginx.conf.j2'
+ dest: '/etc/nginx/sites-available/{{ item.app }}'
+ mode: '644'
+ loop: '{{ nginx_apps_confs }}'
+ notify:
+ - 'nginx_restart'
+
+- name: 'Remove the old symbolic link for apps'
+ file:
+ path: '/etc/nginx/sites-enabled/{{ item.app }}'
+ state: 'absent'
+ loop: '{{ nginx_apps_confs }}'
+
+- name: 'Create a http symbolic link for apps'
+ file:
+ src: '/etc/nginx/sites-available/{{ item.app }}'
+ dest: '/etc/nginx/sites-enabled/{{ item.app }}'
+ state: 'link'
+ loop: '{{ nginx_apps_confs }}'
+
+- name: 'Check nginx config' # noqa no-changed-when
+ command: 'nginx -t'