ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
816 stars 1.5k forks source link

[PR #8471/2574cb0d backport][stable-9] feat: proxmox_vm_info - add network information for guests #8505

Closed patchback[bot] closed 3 months ago

patchback[bot] commented 3 months ago

This is a backport of PR #8471 as merged into main (2574cb0dea23008be2cc158310523b00e72354d4).

SUMMARY

Information of guests should include current network settings to support waiting on network settings when provisioning new machines. The methods for accessing the information are already present in the API and only need to be called.

The retrieval of network information can be enabled/disabled via new bool param network (default=false)

For qemu vms, agent must be enabled and running. Otherwise, a clear error message from the API is shown: "msg": "Failed to retrieve QEMU VMs information: 500 Internal Server Error: QEMU guest agent is not running"

For lxc containers, the information is always there.

ISSUE TYPE
COMPONENT NAME

proxmox_vm_info

ADDITIONAL INFORMATION

Information of guests should include current network settings to support waiting on network settings when provisioning new machines. The methods for accessing the information are already present in the API and only need to be called.

New list of network interfaces in the result:

(QEMU)
[...]
"network": [
                    {
                        "hardware-address": "00:00:00:00:00:00",
                        "ip-addresses": [
                            {
                                "ip-address": "127.0.0.1",
                                "ip-address-type": "ipv4",
                                "prefix": 8
                            },
                            {
                                "ip-address": "::1",
                                "ip-address-type": "ipv6",
                                "prefix": 128
                            }
                        ],
                        "name": "lo",
                        "statistics": {
                            "rx-bytes": 5920,
                            "rx-dropped": 0,
                            "rx-errs": 0,
                            "rx-packets": 80,
                            "tx-bytes": 5920,
                            "tx-dropped": 0,
                            "tx-errs": 0,
                            "tx-packets": 80
                        }
                    },
                    {
                        "hardware-address": "bc:24:XX:XX:73:6d",
                        "ip-addresses": [
                            {
                                "ip-address": "192.168.XXX.XXX",
                                "ip-address-type": "ipv4",
                                "prefix": 24
                            },
                            {
                                "ip-address": "fe80::be24:XXXX:XXXX:736d",
                                "ip-address-type": "ipv6",
                                "prefix": 64
                            }
                        ],
                        "name": "ens18",
                        "statistics": {
                            "rx-bytes": 6134,
                            "rx-dropped": 30,
                            "rx-errs": 0,
                            "rx-packets": 51,
                            "tx-bytes": 1016,
                            "tx-dropped": 0,
                            "tx-errs": 0,
                            "tx-packets": 6
                        }
                    }
                ],
[...]

(LXC)
[...]
                "network": [
                    {
                        "hwaddr": "00:00:00:00:00:00",
                        "inet": "127.0.0.1/8",
                        "inet6": "::1/128",
                        "name": "lo"
                    },
                    {
                        "hwaddr": "82:00:XX:XX:84:f8",
                        "inet": "192.168.XXX.XXX/24",
                        "inet6": "fe80::8000:XXXX:XXXX:84f8/64",
                        "name": "eth0"
                    }
                ],
[...]
ansibullbot commented 3 months ago

cc @Ajpantuso @Thulium-Drake @UnderGreen @joshainglis @karmab @krauthosting click here for bot help