Ansible - Proxmox

We recently stood up a Proxmox cluster to replace an old ESXI setup and a KVM host. I nearly broke myself had some fun making this work nicely and decided to do a bit of documenting to help me remember the sticking points.

This took a while to get working correctly. Partly this was down to some missing documentation but there was also a bit of ignorance going on.

It's not working!

Things to check if you are getting rubbish errors when creating VMs or CTs:

  1. Make sure that ansible -m ping proxmoxhost works.
  2. Make sure that proxmoxer and requests are installed on the proxmox hosts as well as the ansible host. Install via PIP. The documentation I found on line makes it clear you don't need to do this but it utterly refused to work until I'd installed them.

Multiple NICs

Multiple NICS for containers took a bit of figuring out. The errors from the module aren't exactly good for debugging. This is my task which works:

    - name: Container Creation
        api_user: root@pam
        api_host: 172.25.x.x
        disk: 20
        node: krakatoa
        api_password: passwordhere
        password: passwordhere
        hostname: lxc-gitlab
        validate_certs: no
        storage: local-lvm
        cpus: 2
        memory: 4096
        swap: 4096
        pubkey: 'ssh-rsa gibberishkeyhere jagdpanther'
        onboot: yes
        ostemplate: 'local:vztmpl/debian-9.0-standard_9.0-2_amd64.tar.gz'
        nameserver: x.x.x.x
        netif: {"net1":"name=eth1,gw=,ip=,bridge=vmbr0","net2":"name=eth2,gw=,ip=,bridge=vmbr1"}