--- - name: Ensure frontend dir exists file: path: "{{ item }}" owner: nonroot group: nonroot state: directory mode: '0755' with_items: - "/home/nonroot/frontend/html" - "/home/nonroot/frontend/config" - name: Copy the frontend files copy: src: "{{ item.file }}" dest: "/home/nonroot/frontend/{{ item.dest }}" owner: nonroot group: nonroot with_items: - { file: 'index.html', dest: "html" } - { file: 'nginx.conf', dest: "config" } - name: Start an nginx image to serve the files community.docker.docker_container: name: frontend image: nginx links: - backend ports: - "80:80" volumes: - /home/nonroot/frontend/html:/usr/share/nginx/html - /home/nonroot/frontend/config/nginx.conf:/etc/nginx/conf.d/default.conf become_user: nonroot