kmpm / ansible-collection-incus

Collection of Ansible plugins for dealing with Incus from Linuxcontainers
GNU General Public License v3.0
14 stars 6 forks source link

inventory plugin does not set ansible_incus_project on the hosts #15

Closed flku-snp closed 11 hours ago

flku-snp commented 1 month ago

When I filter by project , I still have to globally add it back, see -e ansible_incus_project=

16:00:05 /tmp/incus_connect $ cat incus.yaml
plugin: kmpm.incus.incus
type_filter: all
#state_filter: running
project: test

16:00:13 /tmp/incus_connect $ ansible-inventory -i incus.yaml  --list
{
    "_meta": {
        "hostvars": {
            "node1": {
                "ansible_connection": "community.general.incus",
                "ansible_host": "node1",
                "ansible_incus_architecture": "x86_64",
                "ansible_incus_location": "none",
                "ansible_incus_os": "Debian",
                "ansible_incus_profiles": [
                    "test_df_profile"
                ],
                "ansible_incus_release": "bookworm",
                "ansible_incus_status": "running",
                "ansible_incus_type": "container",
                "ansible_incus_vlan_ids": null
            },
            "node2": {
                "ansible_connection": "community.general.incus",
                "ansible_host": "node2",
                "ansible_incus_architecture": "x86_64",
                "ansible_incus_location": "none",
                "ansible_incus_os": "Debian",
                "ansible_incus_profiles": [
                    "default"
                ],
                "ansible_incus_release": "bookworm",
                "ansible_incus_status": "running",
                "ansible_incus_type": "container",
                "ansible_incus_vlan_ids": null
            }
        }
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    },
    "ungrouped": {
        "hosts": [
            "node1",
            "node2"
        ]
    }
}

16:00:21 /tmp/incus_connect $ ansible-playbook -i incus.yaml -i groups  hello-world.yaml -e ansible_incus_project=test

PLAY [Testplay ping] ********************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************************************************************
Friday 18 October 2024  16:01:19 +0200 (0:00:00.721)       0:00:00.721 ********
fatal: [node2]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "failed": true, "module_stderr": "/bin/sh: 1: /usr/bin/python: not found\nError: Command not found\n", "module_stdout": "", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127, "warnings": ["No python interpreters found for host node2 (tried ['python3.12', 'python3.11', 'python3.10', 'python3.9', 'python3.8', 'python3.7', 'python3.6', '/usr/bin/python3', '/usr/libexec/platform-python', 'python2.7', '/usr/bin/python', 'python'])"]}}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"}
ok: [node1]

TASK [Ping] *****************************************************************************************************************************************************************************************************************************
Friday 18 October 2024  16:01:20 +0200 (0:00:01.239)       0:00:01.961 ********
ok: [node1]

PLAY RECAP ******************************************************************************************************************************************************************************************************************************
node1                      : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
node2                      : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Playbook run took 0 days, 0 hours, 0 minutes, 2 seconds
Friday 18 October 2024  16:01:21 +0200 (0:00:00.772)       0:00:02.734 ********
===============================================================================
gather_facts ------------------------------------------------------------ 1.24s
ansible.builtin.ping ---------------------------------------------------- 0.77s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
total ------------------------------------------------------------------- 2.01s

16:01:21 /tmp/incus_connect $