Ansible community.general.proxmox: can't create containers

starkruzr

Well-Known Member
Has anyone successfully used this module? I have tried to follow the directions here and appear to be stuck on something stupid: https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_module.html

I have installed the module via ansible-galaxy. As far as I can tell the usual Ansible "hosts" inventory is just not used for this module, but if it is I cannot see how from these directions. Here is an example from my .yml:

YAML:
# Deploys Arvados container hosts

- hosts: localhost

  tasks:
  - name: Create API container
    community.general.proxmox:
      vmid: 500
      node: ibnmajid
      api_user: root@pam
      api_password: setecastronomy
      api_host: ibnmajid
      password: setecastronomy
      hostname: arvados-api
      ostemplate: 'largewrxFS:vztmpl/ubuntu-20.04-standard_20.04-1_amd64.tar.gz'
      cores: 1
      memory: 2048
      disk: 40
      storage: fastwrx
      mounts: '{"mp0":"largewrxFS:/arvadosdata/,mp=/mnt/arvadosdata/"}'
      netif: '{"net0":"name=eth0,gw=192.168.9.1,ip=192.168.9.80/24,bridge=vmbr0"}'
      unprivileged: no
      validate_certs: no
      onboot: yes
      description: container for Arvados API server

(fake pass, obviously)
Then I have more -name entries with more containers to create. This fails over and over. I tried creating a basic hosts.yml as a dummy, but that didn't help.

Code:
jtd@Picon:~/arvados-cluster$ ansible-playbook arvados-deploy-hosts.yml -i hosts.yml

PLAY [localhost] *****************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************
ok: [localhost]

TASK [Create API container] ******************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: deprecate() got an unexpected keyword argument 'collection_name'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/jtd/.ansible/tmp/ansible-tmp-1613891679.837745-47033749956554/AnsiballZ_proxmox.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/jtd/.ansible/tmp/ansible-tmp-1613891679.837745-47033749956554/AnsiballZ_proxmox.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/jtd/.ansible/tmp/ansible-tmp-1613891679.837745-47033749956554/AnsiballZ_proxmox.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.proxmox', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.general.proxmox_payload_y_kcagyv/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/modules/proxmox.py\", line 706, in <module>\n  File \"/tmp/ansible_community.general.proxmox_payload_y_kcagyv/ansible_community.general.proxmox_payload.zip/ansible_collections/community/general/plugins/modules/proxmox.py\", line 546, in main\nTypeError: deprecate() got an unexpected keyword argument 'collection_name'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP ***********************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

I am *guessing* you use "localhost" for the Ansible "host" because the details for each created container contain the API host you are connecting to and executing commands on. If that isn't how it works it is super unclear from the documentation. Can anyone explain this to me?

TIA.
 
Hello,

what's the ansible version?
Code:
jtd@Picon:~$ ansible --version
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/jtd/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
 
So, updating to 3.0.0 actually seems to have helped solve this. Also I changed my hosts.yml to just be the api host I'm using and that seems to have resolved that part of the issue.

My problem now is that my mount point doesn't work. I had to comment it out in order to get the containers to create. "largewrxFS" is a cephFS filesystem, but I get this:

Code:
fatal: [ibnmajid]: FAILED! => {"changed": false, "msg": "creation of lxc VM 500 failed with exception: 400 Bad Request: Parameter verification failed. - b'{\"data\":null,\"errors\":{\"storage\":\"storage \\'largewrxFS\\' does not support container directories\"}}'"}

And like, yes it does, I have it mounted on other containers!
 
Can you try with ansible 2.9.10 or higher? When I tried ansible on Ubuntu with proxmox_kvm module, it complained about versions, so I had to switch to Fedora (it had 2.9.15, now it's 2.9.17) and it worked.

I tried the following playbook on Fedora and it worked:
YAML:
- hosts: localhost

  tasks:
  - name: Create API container
    community.general.proxmox:
      vmid: "500"
      node: office-proxmox01
      api_user: root@pam
      api_password: _PASS_
      api_host: office-proxmox01.internal.domain
      password: 123456
      hostname: arvados-api
      ostemplate: 'local:vztmpl/ubuntu-20.04-standard_20.04-1_amd64.tar.gz'
      cores: 1
      memory: 2048
      disk: "40"
      storage: fc_store_thin
#      mounts: '{"mp0":"largewrxFS:/arvadosdata/,mp=/mnt/arvadosdata/"}'
      netif: '{"net0":"name=eth0,gw=192.168.9.1,ip=192.168.9.80/24,bridge=vmbr0"}'
      unprivileged: no
      validate_certs: no
      onboot: yes
      description: container for Arvados API server
 
The module is using web API.

Regards
On my side is work with SSH

Code:
- hosts: proxmox
  tasks:
    - name: Create container for PVE
      community.general.proxmox:
        node: my_node
        api_user: root@pam
        api_password: my_pwd
        api_host: my_ip
        password: 123456
        hostname: 1.org
        cores: 1
        memory: 512
        swap: 512
        disk: 8
        storage: storage
        unprivileged: no
        description: Container with Ansible
        ostemplate: 'local:vztmpl/debian-10-standard_10.7-1_amd64.tar.gz'
        proxmox_default_behavior: no_defaults
        onboot: no
        netif: '{"net0":"name=eth0,gw=192.168.0.1,ip=192.168.0.2/24,bridge=vmbr0"}'
        features:
         - nesting=1

What you have set in your : hosts.yml ?

Best Regards
 
Last edited:
Hi I'm using

Code:
Package       Version
------------- ---------
ansible       4.6.0
ansible-core  2.11.5
proxmoxer     1.2.0b1


I've added the following line as without it I cannot run my Version 6 containers in Proxmox 7:

YAML:
features: nesting=1

Here is the entire command:

YAML:
- name: 'create Cts'
  community.general.proxmox:
    vmid: '{{ network_new[sel_env].vmidprefix }}{{ hostvars[item].vmid }}'
    onboot: '{{ hostvars[item].onboot }}'
    api_user: "{{ network_new[sel_env].api_user}}"
    api_password: "{{ network_new[sel_env].api_password}}"
    api_host: "{{ network_new[sel_env].api_host}}"
    node: '{{ network_new[sel_env].node}}'
    memory: '{{ hostvars[item].memory}}'
    hostname: "{{ hostvars[item].name }}"
    cores: '{{ hostvars[item].cores}}'
    disk:  '{{ hostvars[item].disk}}'
    searchdomain: '{{ network_new[sel_env].searchdomain }}'
    nameserver: "{{ network_new['public'].gateway}}"
    netif: '{"net0":"name=eth0,hwaddr={{ hostvars[item].macaddr}},gw={{ network_new[sel_env].gateway}},ip={{network_new[sel_env].subnetprefix}}.{{ hostvars[item].ipaddr}}/24,bridge=vmbr{{ network_new[sel_env].vmbr}}"}'
    storage: local-lvm
    ostemplate: '{{ hostvars[item].ostemplate}}' 
    password: '{{ network_new[sel_env].host_password}}'
    unprivileged: 1
    features: 
     - nesting=1
    pubkey:  '{{ hostvars[item].sshpubkey}}'
    proxmox_default_behavior: no_defaults
    state: 'present'

Error: I get is:
failed: [pve -> pve] (item=jumpbox) => {"ansible_loop_var": "item", "changed": false, "item": "jumpbox", "msg": "Unsupported parameters for (proxmox) module: features. Supported parameters include: api_host, memory, pool, state, cpus, password, swap, validate_certs, onboot, vmid, api_token_id, disk, node, hookscript, api_password, mounts, nameserver, ostemplate, hostname, cores, force, searchdomain, cpuunits, netif, unprivileged, proxmox_default_behavior, api_user, api_token_secret, pubkey, storage, timeout, description, ip_address."}

The above does not mention that it supports the 'nesting' attribute but should as I'm using Ansible 4.6 and Proxmoxer 1.2.0b1.

What am I missing here pls?

Any help would be might appreciated.

TIA
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!