diff options
| author | Kumar <kumar@kumardamani.xyz> | 2021-11-23 14:59:08 +0000 |
|---|---|---|
| committer | Kumar Damani <me@kumardamani.net> | 2022-03-25 19:45:25 +0000 |
| commit | a857eb82ec9c4a79ad5e41462e2ab82c2660982e (patch) | |
| tree | 9ca51ddfb551322bd4d2fa3f949fa8898032632d /roles/nginx/tasks | |
initial commit
Diffstat (limited to 'roles/nginx/tasks')
| -rw-r--r-- | roles/nginx/tasks/main.yaml | 67 |
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' |
