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

Inventory iocage fails when DHCP is enbled. #9538

Open
1 task done
vbotka opened this issue Jan 6, 2025 · 3 comments · May be fixed by #9539
Open
1 task done

Inventory iocage fails when DHCP is enbled. #9538

vbotka opened this issue Jan 6, 2025 · 3 comments · May be fixed by #9539
Labels
bug This issue/PR relates to a bug has_pr plugins plugin (any type)

Comments

@vbotka
Copy link
Contributor

vbotka commented Jan 6, 2025

Summary

When DHCP is enabled, for example

shell> iocage get dhcp test_111
1

the iocage binary reports in IP4 tab 'DHCP (not running)' when STATE is down

shell> iocage list -l
+------+----------------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| JID  |      NAME      | BOOT | STATE | TYPE |     RELEASE     |        IP4         | IP6 |    TEMPLATE    | BASEJAIL |
+======+================+======+=======+======+=================+====================+=====+================+==========+
| None | ansible_client | off  | down  | jail | 14.1-RELEASE-p6 | -                  | -   | -              | yes      |
+------+----------------+------+-------+------+-----------------+--------------------+-----+----------------+----------+
| None | test_111       | off  | down  | jail | 14.1-RELEASE-p6 | DHCP (not running) | -   | ansible_client | yes      |
+------+----------------+------+-------+------+-----------------+--------------------+-----+----------------+----------+

The inventory plugin community.general.iocage cannot parse this IP4 message.

Issue Type

Bug Report

Component Name

plugins/inventory/iocage.py

Ansible Version

$ ansible --version
ansible [core 2.18.1]
  config file = /home/vlado/.ansible.cfg
  configured module search path = ['/home/vlado/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vlado/env/lib/python3.12/site-packages/ansible
  ansible collection location = /home/vlado/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vlado/env/bin/ansible
  python version = 3.12.3 (main, Nov  6 2024, 18:32:19) [GCC 13.2.0] (/home/vlado/env/bin/python3)
  jinja version = 3.1.4
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
Collection        Version
----------------- -------
community.general 10.2.0 

Configuration

$ ansible-config dump --only-changed
<irrelevant>

OS / Environment

shell> cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.1 LTS"

Steps to Reproduce

Given the inventory configuration

shell> cat iocage.yml 
plugin: community.general.iocage
host: 10.1.0.73
user: admin

the ansible-inventory fails

shell> ansible-inventory -i iocage.yml --list --yaml
[WARNING]:  * Failed to parse
/scratch/examples/018/iocage.yml with auto plugin:
list index out of range
  ...

The function _parse_ip4 cannot parse the DHCP message.

See https://github.com/ansible-collections/community.general/blob/main/plugins/inventory/iocage.py#L131

Expected Results

Parse IP4 message. For example,

shell> ansible-inventory -i iocage.yml --list --yaml
all:
  children:
    ungrouped:
      hosts:
        ansible_client:
          iocage_basejail: 'yes'
          iocage_boot: 'off'
          iocage_ip4_dict:
            ip4: []
            msg: '-'
          iocage_ip4: '-'
          iocage_ip6: '-'
          iocage_jid: None
          iocage_release: 14.1-RELEASE-p6
          iocage_state: down
          iocage_template: '-'
          iocage_type: jail
        test_111:
          iocage_basejail: 'yes'
          iocage_boot: 'off'
          iocage_ip4_dict:
            ip4: []
            msg: DHCP (not running)
          iocage_ip4: '-'
          iocage_ip6: '-'
          iocage_jid: None
          iocage_release: 14.1-RELEASE-p6
          iocage_state: down
          iocage_template: ansible_client
          iocage_type: jail

Actual Results

shell> ansible-inventory -i iocage.yml --list --yaml
[WARNING]:  * Failed to parse
/scratch/examples/018/iocage.yml with auto plugin:
list index out of range
  ...

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
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) labels Jan 6, 2025
vbotka added a commit to vbotka/community.general that referenced this issue Jan 6, 2025
@vbotka vbotka linked a pull request Jan 6, 2025 that will close this issue
@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 removed the module module label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants