Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxd_container: Documentation could mention that config values need to be string #8307

Open
1 task done
nilsmeyer opened this issue May 5, 2024 · 1 comment
Open
1 task done
Labels
docs module module plugins plugin (any type)

Comments

@nilsmeyer
Copy link
Contributor

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

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot ansibullbot added docs module module plugins plugin (any type) labels May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs module module plugins plugin (any type)
Projects
None yet
Development

No branches or pull requests

2 participants