Hi, got Proxmox installed. Now want to install some VMs but would like to use a simple setup rather than painfully going trough an install. I’ve read I could accomplish this via ansible. Are there ready playbooks you can hack? Presumably I would need to have Proxmox understand playbooks?

  • vegetaaaaaaa@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    8 hours ago

    If you needs are simple, write a simple playbook using the proxmox ansible module https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_kvm_module.html

    Terraform/Opentofu provides more advanced stuff but then you have to worry about persistent state storage, the clunky DSL… used it when acsolutely needed, you can do 90% of this stuff with the proxmox ansible module.

    If you need to make your playbook less verbose, move the logic to a role so that you can configure your VMs from a few lines in the playbook/host_vars. Mine looks like this (it’s for libvirt and not proxmox, but the logic is the same)

    # playbook.yml
    - hosts: hypervisor.example.org
      roles:
        - libvirt
    
    # host_vars/hypervisor.example.org.yml
    libvirt_vms:
      - name: vm1.example.org
        xml_file: "{{ playbook_dir }}/data/libvirt/vm1.example.org.xml"
        state: running
        autostart: yes
      - name: vm2.example.org
        xml_file: "{{ playbook_dir }}/data/libvirt/vm2.example.org.xml"
        autostart: no
      - name: vm3.example.org
        xml_file: "{{ playbook_dir }}/data/libvirt/vm3.example.org.xml"
        autostart: no
      - name: vm4.example.org
        xml_file: "{{ playbook_dir }}/data/libvirt/vm4.example.org.xml"
        autostart: no
        disk_size: 100G