---
- name: Fix Warden docker-compose.yml
  hosts: warden
  become: yes
  gather_facts: no

  tasks:
    - name: Ensure /opt/warden directory exists
      file:
        path: /opt/warden
        state: directory
        owner: root
        group: root
        mode: '0755'

    - name: Create or update docker-compose.yml with correct indentation
      copy:
        dest: /opt/warden/docker-compose.yml
        content: |
          services:
            vaultwarden:
              image: hub.git4ta.fun/vaultwarden/server:latest
              security_opt:
                - "seccomp=unconfined"
              env_file:
                - .env
              volumes:
                - ./data:/data
              ports:
                - "980:80"
              restart: always
              networks:
                - vaultwarden_network

          networks:
            vaultwarden_network:
        owner: root
        group: root
        mode: '0644'