# 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'