community.general
community.general copied to clipboard
lxd_container: Documentation could mention that config values need to be string
Summary
When lxd_container passes the configuration from the config option to LXD or Incus and the values used aren't strings you might end up seeing an error "json: cannot unmarshal number into Go struct field InstancesPost.config of type string", an example:
- name: Create molecule instance(s)
community.general.lxd_container:
name: "mycontainer"
state: started
config:
"limits.cpu": 2
source:
type: image
mode: pull
protocol: simplestreams
alias: almalinux/9/cloud
wait_for_ipv4_addresses: true
While correct synax would be:
- name: Create molecule instance(s)
community.general.lxd_container:
name: "mycontainer"
state: started
config:
"limits.cpu": "2"
source:
type: image
mode: pull
protocol: simplestreams
alias: almalinux/9/cloud
wait_for_ipv4_addresses: true
It took me a while to figure this out. My suggestion would be to add a point to the Documentation for the config: parameter that LXD/Incus expect the values to always be strings.
Issue Type
Documentation Report
Component Name
lxd_container
Ansible Version
ansible [core 2.16.6]
config file = /home/nils/.ansible.cfg
configured module search path = ['/home/nils/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/nils/.local/pipx/venvs/ansible/lib/python3.11/site-packages/ansible
ansible collection location = /home/nils/.ansible/collections:/usr/share/ansible/collections
executable location = /home/nils/.local/bin/ansible
python version = 3.11.6 (main, Oct 8 2023, 05:06:43) [GCC 13.2.0] (/home/nils/.local/pipx/venvs/ansible/bin/python)
jinja version = 3.1.2
libyaml = True
Community.general Version
# /home/nils/.ansible/collections/ansible_collections
Collection Version
----------------- -------
community.general 8.5.0
# /home/nils/.local/pipx/venvs/ansible/lib/python3.11/site-packages/ansible_collections
Collection Version
----------------- -------
community.general 8.6.0
Configuration
CONFIG_FILE() = /home/nils/.ansible.cfg
DEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /home/nils/.local/bin/vault_pass.sh
EDITOR(env: EDITOR) = vim
PAGER(env: PAGER) = less
OS / Environment
- Ubuntu Linux 24.04
- incus 6.0.0
Additional Information
Clarify the format of the config parameter to lxd_container
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct