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