- name: Check that the '/etc/pve/.version' exists
  ansible.builtin.stat:
    path: /etc/pve/.version
  register: stat_result

- name: Perform Proxmox setup
  when:
    - ansible_distribution == 'Debian'
    - stat_result.stat.exists
  block:

    - name: Proxmox VE - delete "enterprise" repo
      ansible.builtin.file:
        path: /etc/apt/sources.list.d/pve-enterprise.list
        state: absent

    - name: Proxmox VE - add "no subscription" repo
      ansible.builtin.copy:
        content: |
          deb [arch=amd64] http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-no-subscription
        dest: /etc/apt/sources.list.d/pve-no-subscription.list
        owner: root
        group: root
        mode: "0644"
        force: true
