--- - ansible.builtin.blockinfile: path: /etc/nginx/nginx.conf block: | upstream storage_nemunaire { {% for server in s3_hosts %} server {{ server.host }}:{{ server.port | default(9000) }}{% if server.backup is defined and server.backup %} backup{% endif %}; {% endfor %} } insertafter: 'http {' marker: "# {mark} ANSIBLE MANAGED BLOCK storage_nemunaire" - ansible.builtin.set_fact: server: | location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header Authorization ""; proxy_intercept_errors on; chunked_transfer_encoding off; proxy_pass https://storage_nemunaire/{{ bucket }}{{ path }}/; {% for error_page in error_pages %} error_page {{ error_page }} /{{ error_pages[error_page] }}; {% endfor %} #try_files $uri $uri/index.html $uri.html =404; } location ~ /$ { rewrite ^(.*)/ $1/index.html; } when: server is not defined - ansible.builtin.include_role: name: re.nemunai.nginx-config-svc