- name: Gitea
  hosts: beepi
  become: true
  vars:
    gitea_db_password: !vault |
              $ANSIBLE_VAULT;1.1;AES256
              63336533393735346165633965383866393736336365646330346236356239363737353234383637
              6261383166323062663033346136633066303462343263320a333932646162336232373530373834
              65386637336562646135613563356137313239336365653161386434313835633437613233343332
              3736353865313938300a383266353538666135353866653263663133663232646430323966353134
              3939
  tasks:
    - name: Install podman
      ansible.builtin.apt:
        name: podman
        state: present

    - name: Install podman-compose
      ansible.builtin.apt:
        name: podman-compose
        state: present

    - name: Create gitea directory
      ansible.builtin.file:
        path: /opt/beeserver/gitea
        state: directory
        mode: '0755'

    - name: Compose down
      changed_when: true
      failed_when: false
      ansible.builtin.command:
        cmd: podman-compose down
        chdir: /opt/beeserver/gitea

    - name: Copy compose
      ansible.builtin.template:
        src: docker-compose.yml.j2
        dest: /opt/beeserver/gitea/docker-compose.yml
        mode: '0644'

    - name: Compose up
      changed_when: true
      ansible.builtin.command:
        cmd: podman-compose up -d
        chdir: /opt/beeserver/gitea
