This guide explains how to install Proxmox on a Debian 12 machine using Ansible.

Preparing/installing the target machine

During the installation of Debian please keep the software group standard system utilities checked:

Installation settings

If you did not do this, some errors will occur when running Ansible, e.g. about missing Python, and Python-apt. This can be solved by installing these packages, and symbolic linking them into Pythons packages:

apt install python3 python3-apt

cd /usr/lib/python3/dist-packages
ln -s apt_inst.cpython-35m-x86_64-linux-gnu.so apt_inst.so
ln -s apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so

Ansible playbook

Now that we have a target machine, we can go and install Proxmox on it. For this playbook https://pve.proxmox.com/wiki/Install_Proxmox_VE_on_Debian_12_Bookworm was used as a reference.

---
    - name: Docker playbook
      hosts:
        - all
      tasks:
      - name: Fix hosts entries (remove localhost references 1/2)
        ansible.builtin.lineinfile:
          path: /etc/hosts
          search_string: '127.0.0.1'
          line: ""
          owner: root
          group: root
          mode: '0644'
      - name: Fix hosts entries (remove localhost references 2/2)
        ansible.builtin.lineinfile:
          path: /etc/hosts
          search_string: '127.0.1.1'
          line: ""
          owner: root
          group: root
          mode: '0644'
      - name: Fix hosts entries (adding localhost reference)
        ansible.builtin.lineinfile:
          path: /etc/hosts
          search_string: '127.0.0.1'
          line: "127.0.0.1       localhost.localdomain localhost"
          owner: root
          group: root
          mode: '0644'
      - name: Fix hosts entries (add Proxmox FQDN)
        ansible.builtin.lineinfile:
          path: /etc/hosts
          search_string: '127.0.0.1'
          line: "192.168.15.77   debian.proxmox.com debian"
          owner: root
          group: root
          mode: '0644'

      - name: Download Proxmox release public key with check (sha512)
        ansible.builtin.get_url:
          url: https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg
          dest: /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg
          checksum: sha512:7da6fe34168adc6e479327ba517796d4702fa2f8b4f0a9833f5ea6e6b48f6507a6da403a274fe201595edc86a84463d50383d07f64bdde2e3658108db7d6dc87
          mode: '0444'
      - name: Add source Proxmox repository into sources list
        ansible.builtin.apt_repository:
          repo: "deb [arch=amd64] http://download.proxmox.com/debian/pve bookworm pve-no-subscription"
          state: "present"
      - name: Update apt cache
        apt:
          update_cache: yes
 
      - name: Update and upgrade base
        apt:
          update_cache: yes
          state: latest
          autoclean: yes
          autoremove: yes
      - name: Installing Proxmox
        apt:
          pkg:
            - proxmox-ve
            - postfix
            - open-iscsi
            - ifupdown2 # With ifupdown2 you can apply a new network configuration to the host without rebooting it. 
          state: present
      - name: Remove "os-prober" package
        # The os-prober package scans all the partitions of your host,
        # including those assigned to guests VMs, to create dual-boot GRUB
        # entries. If you didn't install Proxmox VE as dual boot beside another
        # Operating System, you can safely remove the os-prober package. 
        ansible.builtin.apt:
          name: os-prober
          state: absent

When executing the playbook, the following output should be visible:

SSH password: 

PLAY [Docker playbook] **********************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
ok: [root@192.168.5.22]

TASK [Fix hosts entries (remove localhost references 1/2)] **********************************************************************************************************************************************************************************
changed: [root@192.168.5.22]

TASK [Fix hosts entries (remove localhost references 2/2)] **********************************************************************************************************************************************************************************
changed: [root@192.168.5.22]

TASK [Fix hosts entries (adding localhost reference)] ***************************************************************************************************************************************************************************************
changed: [root@192.168.5.22]

TASK [Fix hosts entries (add Proxmox FQDN)] *************************************************************************************************************************************************************************************************
changed: [root@192.168.5.22]

TASK [Download Proxmox release public key with check (sha512)] ******************************************************************************************************************************************************************************
changed: [root@192.168.5.22]

TASK [Add source Proxmox repository into sources list] **************************************************************************************************************************************************************************************
changed: [root@192.168.5.22]

TASK [Update apt cache] *********************************************************************************************************************************************************************************************************************
ok: [root@192.168.5.22]

TASK [Update and upgrade base] **************************************************************************************************************************************************************************************************************
ok: [root@192.168.5.22]

TASK [Installing Proxmox] *******************************************************************************************************************************************************************************************************************
changed: [root@192.168.5.22]

TASK [Remove "os-prober" package] ***********************************************************************************************************************************************************************************************************
changed: [root@192.168.5.22]

PLAY RECAP **********************************************************************************************************************************************************************************************************************************
root@192.168.5.22          : ok=11   changed=8    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

The stage Installing Proxmox can take a while

After the installation the Proxmox should be available for use: Proxmox post-installation