From a857eb82ec9c4a79ad5e41462e2ab82c2660982e Mon Sep 17 00:00:00 2001 From: Kumar Date: Tue, 23 Nov 2021 09:59:08 -0500 Subject: initial commit --- roles/nginx/tasks/main.yaml | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 roles/nginx/tasks/main.yaml (limited to 'roles/nginx/tasks') 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' -- cgit v1.2.3