Não sei se alguém passou por isso, mas eu costumava imprimir as variáveis que são coletadas no ansible com "gather_facts" da seguinte forma num arquivo print-facts.yml:
- name: Print all available facts
ansible.builtin.debug:
var: ansible_facts
Eu simplesmente criava esse playbook e rodava:
ansible-playbook -i inventory print-facts.yml
Agora descobri que existe um jeito bem mais fácil: ansible <host> -i inventory -m setup
Um exemplo daqui:
ansible helio -i inventory -m setup
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
helio | SUCCESS => {
"ansible_facts": {
"ansible_all_ipv4_addresses": [
"1.2.3.4",
"10.13.8.45"
],
"ansible_all_ipv6_addresses": [
"1:2:3:4::beba:cafe",
"fe80::e0c3:aeff:fe14:6b3a",
"fe80::e0c3:aeff:fe14:34b",
"fe80::e0c3:aeff:fe14:d46b"
],
"ansible_apparmor": {
"status": "enabled"
},
"ansible_architecture": "x86_64",
"ansible_bios_date": "04/01/2014",
"ansible_bios_vendor": "SeaBIOS",
"ansible_bios_version": "1.16.2-debian-1.16.2-1",
"ansible_board_asset_tag": "NA",
"ansible_board_name": "NA",
"ansible_board_serial": "NA",
"ansible_board_vendor": "NA",
"ansible_board_version": "NA",
"ansible_chassis_asset_tag": "NA",
"ansible_chassis_serial": "NA",
"ansible_chassis_vendor": "QEMU",
"ansible_chassis_version": "pc-i440fx-7.2",
"ansible_cmdline": {
"BOOT_IMAGE": "/boot/vmlinuz-7.0.0-29-generic",
"biosdevname": "0",
"memhp_default_state": "online",
"net.ifnames": "0",
"ro": true,
"root": "UUID=40d456dd-db46-48fa-ae40-844e2be77c66"
},
"ansible_date_time": {
"date": "2026-09-24",
"day": "24",
"epoch": "1790242390",
"epoch_int": "1790242390",
"hour": "09",
"iso8601": "2026-09-24T09:33:10Z",
"iso8601_basic": "20260924T093310805068",
"iso8601_basic_short": "20260924T093310",
"iso8601_micro": "2026-09-24T09:33:10.805068Z",
"minute": "33",
"month": "09",
"second": "10",
"time": "09:33:10",
"tz": "UTC",
"tz_dst": "UTC",
"tz_offset": "+0000",
"weekday": "Thursday",
"weekday_number": "4",
"weeknumber": "38",
"year": "2026"
},
"ansible_default_ipv4": {
"address": "1.2.3.4",
"alias": "eth0",
"broadcast": "",
"gateway": "1.2.3.1",
"interface": "eth0",
"macaddress": "e2:c3:ae:14:03:4b",
"mtu": 1500,
"netmask": "255.255.252.0",
"network": "1.2.3.0",
"prefix": "22",
"type": "ether"
},
"ansible_default_ipv6": {
"address": "1:2:3:4::beba:cafe",
"gateway": "fe80::987e:caff:fe73:2650",
"interface": "eth2",
"macaddress": "e2:c3:ae:14:6b:3a",
"mtu": 1500,
"prefix": "64",
"scope": "global",
"type": "ether"
},
"ansible_device_links": {
"ids": {
"vda": [
"virtio-017424eb7d6d40d0978a"
],
"vda1": [
"virtio-017424eb7d6d40d0978a-part1"
],
"vda2": [
"virtio-017424eb7d6d40d0978a-part2"
]
},
"labels": {},
"masters": {},
"uuids": {
"vda2": [
"40d456dd-db46-48fa-ae40-844e2be77c66"
]
}
},
"ansible_devices": {
"loop0": {
"holders": [],
"host": "",
"links": {
"ids": [],
"labels": [],
"masters": [],
"uuids": []
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "0",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "none",
"sectors": 0,
"sectorsize": "512",
"size": "0.00 Bytes",
"support_discard": "4096",
"vendor": null,
"virtual": 1
},
"loop1": {
"holders": [],
"host": "",
"links": {
"ids": [],
"labels": [],
"masters": [],
"uuids": []
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "0",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "none",
"sectors": 0,
"sectorsize": "512",
"size": "0.00 Bytes",
"support_discard": "0",
"vendor": null,
"virtual": 1
},
"loop2": {
"holders": [],
"host": "",
"links": {
"ids": [],
"labels": [],
"masters": [],
"uuids": []
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "0",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "none",
"sectors": 0,
"sectorsize": "512",
"size": "0.00 Bytes",
"support_discard": "0",
"vendor": null,
"virtual": 1
},
"loop3": {
"holders": [],
"host": "",
"links": {
"ids": [],
"labels": [],
"masters": [],
"uuids": []
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "0",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "none",
"sectors": 0,
"sectorsize": "512",
"size": "0.00 Bytes",
"support_discard": "0",
"vendor": null,
"virtual": 1
},
"loop4": {
"holders": [],
"host": "",
"links": {
"ids": [],
"labels": [],
"masters": [],
"uuids": []
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "0",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "none",
"sectors": 0,
"sectorsize": "512",
"size": "0.00 Bytes",
"support_discard": "0",
"vendor": null,
"virtual": 1
},
"loop5": {
"holders": [],
"host": "",
"links": {
"ids": [],
"labels": [],
"masters": [],
"uuids": []
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "0",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "none",
"sectors": 0,
"sectorsize": "512",
"size": "0.00 Bytes",
"support_discard": "0",
"vendor": null,
"virtual": 1
},
"loop6": {
"holders": [],
"host": "",
"links": {
"ids": [],
"labels": [],
"masters": [],
"uuids": []
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "0",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "none",
"sectors": 0,
"sectorsize": "512",
"size": "0.00 Bytes",
"support_discard": "0",
"vendor": null,
"virtual": 1
},
"loop7": {
"holders": [],
"host": "",
"links": {
"ids": [],
"labels": [],
"masters": [],
"uuids": []
},
"model": null,
"partitions": {},
"removable": "0",
"rotational": "0",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "none",
"sectors": 0,
"sectorsize": "512",
"size": "0.00 Bytes",
"support_discard": "0",
"vendor": null,
"virtual": 1
},
"vda": {
"holders": [],
"host": "SCSI storage controller: Red Hat, Inc. Virtio block device",
"links": {
"ids": [
"virtio-017424eb7d6d40d0978a"
],
"labels": [],
"masters": [],
"uuids": []
},
"model": null,
"partitions": {
"vda1": {
"holders": [],
"links": {
"ids": [
"virtio-017424eb7d6d40d0978a-part1"
],
"labels": [],
"masters": [],
"uuids": []
},
"sectors": 2048,
"sectorsize": 512,
"size": "1.00 MB",
"start": "2048",
"uuid": null
},
"vda2": {
"holders": [],
"links": {
"ids": [
"virtio-017424eb7d6d40d0978a-part2"
],
"labels": [],
"masters": [],
"uuids": [
"40d456dd-db46-48fa-ae40-844e2be77c66"
]
},
"sectors": 41938911,
"sectorsize": 512,
"size": "20.00 GB",
"start": "4096",
"uuid": "40d456dd-db46-48fa-ae40-844e2be77c66"
}
},
"removable": "0",
"rotational": "1",
"sas_address": null,
"sas_device_handle": null,
"scheduler_mode": "mq-deadline",
"sectors": 41943040,
"sectorsize": "512",
"size": "20.00 GB",
"support_discard": "512",
"vendor": "0x1af4",
"virtual": 1
}
},
"ansible_distribution": "Ubuntu",
"ansible_distribution_file_parsed": true,
"ansible_distribution_file_path": "/etc/os-release",
"ansible_distribution_file_variety": "Debian",
"ansible_distribution_major_version": "26",
"ansible_distribution_release": "resolute",
"ansible_distribution_version": "26.04",
"ansible_dns": {
"nameservers": [
"127.0.0.53"
],
"options": {
"edns0": true,
"trust-ad": true
},
"search": [
"."
]
},
"ansible_domain": "",
"ansible_effective_group_id": 0,
"ansible_effective_user_id": 0,
"ansible_env": {
"COLORTERM": "truecolor",
"DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/0/bus",
"HOME": "/root",
"LANG": "en_US.UTF-8",
"LC_ADDRESS": "pt_BR.UTF-8",
"LC_ALL": "en_US.UTF-8",
"LC_CTYPE": "pt_BR.UTF-8",
"LC_IDENTIFICATION": "pt_BR.UTF-8",
"LC_MEASUREMENT": "en_SE.UTF-8",
"LC_MONETARY": "en_SE.UTF-8",
"LC_NAME": "pt_BR.UTF-8",
"LC_NUMERIC": "en_SE.UTF-8",
"LC_PAPER": "pt_BR.UTF-8",
"LC_TELEPHONE": "en_SE.UTF-8",
"LC_TIME": "en_SE.UTF-8",
"LOGNAME": "root",
"PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
"PWD": "/root",
"SHELL": "/bin/bash",
"SHLVL": "0",
"SSH_CLIENT": "94.237.47.208 38832 22",
"SSH_CONNECTION": "94.237.47.208 38832 1.2.3.4 22",
"USER": "root",
"XDG_RUNTIME_DIR": "/run/user/0",
"XDG_SESSION_CLASS": "user",
"XDG_SESSION_ID": "4",
"XDG_SESSION_TYPE": "tty",
"_": "/bin/sh"
},
"ansible_eth0": {
"active": true,
"device": "eth0",
"features": {
"esp_hw_offload": "off [fixed]",
"esp_tx_csum_hw_offload": "off [fixed]",
"generic_receive_offload": "on",
"generic_segmentation_offload": "on",
"highdma": "on [fixed]",
"hsr_dup_offload": "off [fixed]",
"hsr_fwd_offload": "off [fixed]",
"hsr_tag_ins_offload": "off [fixed]",
"hsr_tag_rm_offload": "off [fixed]",
"hw_tc_offload": "off [fixed]",
"l2_fwd_offload": "off [fixed]",
"large_receive_offload": "off [fixed]",
"loopback": "off [fixed]",
"macsec_hw_offload": "off [fixed]",
"ntuple_filters": "off [fixed]",
"receive_hashing": "off [fixed]",
"rx_all": "off [fixed]",
"rx_checksumming": "on [fixed]",
"rx_fcs": "off [fixed]",
"rx_gro_hw": "on",
"rx_gro_list": "off",
"rx_udp_gro_forwarding": "off",
"rx_udp_tunnel_port_offload": "off [fixed]",
"rx_vlan_filter": "on [fixed]",
"rx_vlan_offload": "off [fixed]",
"rx_vlan_stag_filter": "off [fixed]",
"rx_vlan_stag_hw_parse": "off [fixed]",
"scatter_gather": "on",
"tcp_segmentation_offload": "on",
"tls_hw_record": "off [fixed]",
"tls_hw_rx_offload": "off [fixed]",
"tls_hw_tx_offload": "off [fixed]",
"tx_checksum_fcoe_crc": "off [fixed]",
"tx_checksum_ip_generic": "on",
"tx_checksum_ipv4": "off [fixed]",
"tx_checksum_ipv6": "off [fixed]",
"tx_checksum_sctp": "off [fixed]",
"tx_checksumming": "on",
"tx_esp_segmentation": "off [fixed]",
"tx_fcoe_segmentation": "off [fixed]",
"tx_gre_csum_segmentation": "off [fixed]",
"tx_gre_segmentation": "off [fixed]",
"tx_gso_list": "off [fixed]",
"tx_gso_partial": "off [fixed]",
"tx_gso_robust": "on [fixed]",
"tx_ipxip4_segmentation": "off [fixed]",
"tx_ipxip6_segmentation": "off [fixed]",
"tx_nocache_copy": "off",
"tx_scatter_gather": "on",
"tx_scatter_gather_fraglist": "off [fixed]",
"tx_sctp_segmentation": "off [fixed]",
"tx_tcp6_segmentation": "on",
"tx_tcp_accecn_segmentation": "off [fixed]",
"tx_tcp_ecn_segmentation": "on",
"tx_tcp_mangleid_segmentation": "off",
"tx_tcp_segmentation": "on",
"tx_tunnel_remcsum_segmentation": "off [fixed]",
"tx_udp_segmentation": "off [fixed]",
"tx_udp_tnl_csum_segmentation": "off [fixed]",
"tx_udp_tnl_segmentation": "off [fixed]",
"tx_vlan_offload": "off [fixed]",
"tx_vlan_stag_hw_insert": "off [fixed]",
"vlan_challenged": "off [fixed]"
},
"hw_timestamp_filters": [],
"ipv4": {
"address": "1.2.3.4",
"broadcast": "",
"netmask": "255.255.252.0",
"network": "1.2.3.0",
"prefix": "22"
},
"ipv6": [
{
"address": "fe80::e0c3:aeff:fe14:34b",
"prefix": "64",
"scope": "link"
}
],
"macaddress": "e2:c3:ae:14:03:4b",
"mtu": 1500,
"pciid": "virtio0",
"promisc": false,
"speed": -1,
"timestamping": [],
"type": "ether"
},
"ansible_eth1": {
"active": true,
"device": "eth1",
"features": {
"esp_hw_offload": "off [fixed]",
"esp_tx_csum_hw_offload": "off [fixed]",
"generic_receive_offload": "on",
"generic_segmentation_offload": "on",
"highdma": "on [fixed]",
"hsr_dup_offload": "off [fixed]",
"hsr_fwd_offload": "off [fixed]",
"hsr_tag_ins_offload": "off [fixed]",
"hsr_tag_rm_offload": "off [fixed]",
"hw_tc_offload": "off [fixed]",
"l2_fwd_offload": "off [fixed]",
"large_receive_offload": "off [fixed]",
"loopback": "off [fixed]",
"macsec_hw_offload": "off [fixed]",
"ntuple_filters": "off [fixed]",
"receive_hashing": "off [fixed]",
"rx_all": "off [fixed]",
"rx_checksumming": "on [fixed]",
"rx_fcs": "off [fixed]",
"rx_gro_hw": "on",
"rx_gro_list": "off",
"rx_udp_gro_forwarding": "off",
"rx_udp_tunnel_port_offload": "off [fixed]",
"rx_vlan_filter": "on [fixed]",
"rx_vlan_offload": "off [fixed]",
"rx_vlan_stag_filter": "off [fixed]",
"rx_vlan_stag_hw_parse": "off [fixed]",
"scatter_gather": "on",
"tcp_segmentation_offload": "on",
"tls_hw_record": "off [fixed]",
"tls_hw_rx_offload": "off [fixed]",
"tls_hw_tx_offload": "off [fixed]",
"tx_checksum_fcoe_crc": "off [fixed]",
"tx_checksum_ip_generic": "on",
"tx_checksum_ipv4": "off [fixed]",
"tx_checksum_ipv6": "off [fixed]",
"tx_checksum_sctp": "off [fixed]",
"tx_checksumming": "on",
"tx_esp_segmentation": "off [fixed]",
"tx_fcoe_segmentation": "off [fixed]",
"tx_gre_csum_segmentation": "off [fixed]",
"tx_gre_segmentation": "off [fixed]",
"tx_gso_list": "off [fixed]",
"tx_gso_partial": "off [fixed]",
"tx_gso_robust": "on [fixed]",
"tx_ipxip4_segmentation": "off [fixed]",
"tx_ipxip6_segmentation": "off [fixed]",
"tx_nocache_copy": "off",
"tx_scatter_gather": "on",
"tx_scatter_gather_fraglist": "off [fixed]",
"tx_sctp_segmentation": "off [fixed]",
"tx_tcp6_segmentation": "on",
"tx_tcp_accecn_segmentation": "off [fixed]",
"tx_tcp_ecn_segmentation": "on",
"tx_tcp_mangleid_segmentation": "off",
"tx_tcp_segmentation": "on",
"tx_tunnel_remcsum_segmentation": "off [fixed]",
"tx_udp_segmentation": "off [fixed]",
"tx_udp_tnl_csum_segmentation": "off [fixed]",
"tx_udp_tnl_segmentation": "off [fixed]",
"tx_vlan_offload": "off [fixed]",
"tx_vlan_stag_hw_insert": "off [fixed]",
"vlan_challenged": "off [fixed]"
},
"hw_timestamp_filters": [],
"ipv4": {
"address": "10.13.8.45",
"broadcast": "",
"netmask": "255.255.252.0",
"network": "10.13.8.0",
"prefix": "22"
},
"ipv6": [
{
"address": "fe80::e0c3:aeff:fe14:d46b",
"prefix": "64",
"scope": "link"
}
],
"macaddress": "e2:c3:ae:14:d4:6b",
"mtu": 1500,
"pciid": "virtio1",
"promisc": false,
"speed": -1,
"timestamping": [],
"type": "ether"
},
"ansible_eth2": {
"active": true,
"device": "eth2",
"features": {
"esp_hw_offload": "off [fixed]",
"esp_tx_csum_hw_offload": "off [fixed]",
"generic_receive_offload": "on",
"generic_segmentation_offload": "on",
"highdma": "on [fixed]",
"hsr_dup_offload": "off [fixed]",
"hsr_fwd_offload": "off [fixed]",
"hsr_tag_ins_offload": "off [fixed]",
"hsr_tag_rm_offload": "off [fixed]",
"hw_tc_offload": "off [fixed]",
"l2_fwd_offload": "off [fixed]",
"large_receive_offload": "off [fixed]",
"loopback": "off [fixed]",
"macsec_hw_offload": "off [fixed]",
"ntuple_filters": "off [fixed]",
"receive_hashing": "off [fixed]",
"rx_all": "off [fixed]",
"rx_checksumming": "on [fixed]",
"rx_fcs": "off [fixed]",
"rx_gro_hw": "on",
"rx_gro_list": "off",
"rx_udp_gro_forwarding": "off",
"rx_udp_tunnel_port_offload": "off [fixed]",
"rx_vlan_filter": "on [fixed]",
"rx_vlan_offload": "off [fixed]",
"rx_vlan_stag_filter": "off [fixed]",
"rx_vlan_stag_hw_parse": "off [fixed]",
"scatter_gather": "on",
"tcp_segmentation_offload": "on",
"tls_hw_record": "off [fixed]",
"tls_hw_rx_offload": "off [fixed]",
"tls_hw_tx_offload": "off [fixed]",
"tx_checksum_fcoe_crc": "off [fixed]",
"tx_checksum_ip_generic": "on",
"tx_checksum_ipv4": "off [fixed]",
"tx_checksum_ipv6": "off [fixed]",
"tx_checksum_sctp": "off [fixed]",
"tx_checksumming": "on",
"tx_esp_segmentation": "off [fixed]",
"tx_fcoe_segmentation": "off [fixed]",
"tx_gre_csum_segmentation": "off [fixed]",
"tx_gre_segmentation": "off [fixed]",
"tx_gso_list": "off [fixed]",
"tx_gso_partial": "off [fixed]",
"tx_gso_robust": "on [fixed]",
"tx_ipxip4_segmentation": "off [fixed]",
"tx_ipxip6_segmentation": "off [fixed]",
"tx_nocache_copy": "off",
"tx_scatter_gather": "on",
"tx_scatter_gather_fraglist": "off [fixed]",
"tx_sctp_segmentation": "off [fixed]",
"tx_tcp6_segmentation": "on",
"tx_tcp_accecn_segmentation": "off [fixed]",
"tx_tcp_ecn_segmentation": "on",
"tx_tcp_mangleid_segmentation": "off",
"tx_tcp_segmentation": "on",
"tx_tunnel_remcsum_segmentation": "off [fixed]",
"tx_udp_segmentation": "off [fixed]",
"tx_udp_tnl_csum_segmentation": "off [fixed]",
"tx_udp_tnl_segmentation": "off [fixed]",
"tx_vlan_offload": "off [fixed]",
"tx_vlan_stag_hw_insert": "off [fixed]",
"vlan_challenged": "off [fixed]"
},
"hw_timestamp_filters": [],
"ipv6": [
{
"address": "1:2:3:4::beba:cafe",
"prefix": "64",
"scope": "global"
},
{
"address": "fe80::e0c3:aeff:fe14:6b3a",
"prefix": "64",
"scope": "link"
}
],
"macaddress": "e2:c3:ae:14:6b:3a",
"mtu": 1500,
"pciid": "virtio2",
"promisc": false,
"speed": -1,
"timestamping": [],
"type": "ether"
},
"ansible_fibre_channel_wwn": [],
"ansible_fips": false,
"ansible_flags": [
"fpu",
"vme",
"de",
"pse",
"tsc",
"msr",
"pae",
"mce",
"cx8",
"apic",
"sep",
"mtrr",
"pge",
"mca",
"cmov",
"pat",
"pse36",
"clflush",
"mmx",
"fxsr",
"sse",
"sse2",
"syscall",
"nx",
"mmxext",
"fxsr_opt",
"pdpe1gb",
"rdtscp",
"lm",
"rep_good",
"nopl",
"xtopology",
"cpuid",
"extd_apicid",
"tsc_known_freq",
"pni",
"pclmulqdq",
"ssse3",
"fma",
"cx16",
"sse4_1",
"sse4_2",
"x2apic",
"movbe",
"popcnt",
"tsc_deadline_timer",
"aes",
"xsave",
"avx",
"f16c",
"rdrand",
"hypervisor",
"lahf_lm",
"cmp_legacy",
"cr8_legacy",
"abm",
"sse4a",
"misalignsse",
"3dnowprefetch",
"osvw",
"perfctr_core",
"ssbd",
"ibrs",
"ibpb",
"stibp",
"vmmcall",
"fsgsbase",
"tsc_adjust",
"bmi1",
"avx2",
"smep",
"bmi2",
"rdseed",
"adx",
"smap",
"clflushopt",
"clwb",
"sha_ni",
"xsaveopt",
"xsavec",
"xgetbv1",
"clzero",
"xsaveerptr",
"wbnoinvd",
"arat",
"umip",
"rdpid",
"arch_capabilities"
],
"ansible_form_factor": "Other",
"ansible_fqdn": "helio",
"ansible_hostname": "helio",
"ansible_hostnqn": "",
"ansible_interfaces": [
"lo",
"eth2",
"eth0",
"eth1"
],
"ansible_is_chroot": false,
"ansible_iscsi_iqn": "iqn.2004-10.com.ubuntu:01:299f839dd87",
"ansible_kernel": "7.0.0-29-generic",
"ansible_kernel_version": "#29-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 17 20:52:35 UTC 2026",
"ansible_lo": {
"active": true,
"device": "lo",
"features": {
"esp_hw_offload": "off [fixed]",
"esp_tx_csum_hw_offload": "off [fixed]",
"generic_receive_offload": "on",
"generic_segmentation_offload": "on",
"highdma": "on [fixed]",
"hsr_dup_offload": "off [fixed]",
"hsr_fwd_offload": "off [fixed]",
"hsr_tag_ins_offload": "off [fixed]",
"hsr_tag_rm_offload": "off [fixed]",
"hw_tc_offload": "off [fixed]",
"l2_fwd_offload": "off [fixed]",
"large_receive_offload": "off [fixed]",
"loopback": "on [fixed]",
"macsec_hw_offload": "off [fixed]",
"ntuple_filters": "off [fixed]",
"receive_hashing": "off [fixed]",
"rx_all": "off [fixed]",
"rx_checksumming": "on [fixed]",
"rx_fcs": "off [fixed]",
"rx_gro_hw": "off [fixed]",
"rx_gro_list": "off",
"rx_udp_gro_forwarding": "off",
"rx_udp_tunnel_port_offload": "off [fixed]",
"rx_vlan_filter": "off [fixed]",
"rx_vlan_offload": "off [fixed]",
"rx_vlan_stag_filter": "off [fixed]",
"rx_vlan_stag_hw_parse": "off [fixed]",
"scatter_gather": "on",
"tcp_segmentation_offload": "on",
"tls_hw_record": "off [fixed]",
"tls_hw_rx_offload": "off [fixed]",
"tls_hw_tx_offload": "off [fixed]",
"tx_checksum_fcoe_crc": "off [fixed]",
"tx_checksum_ip_generic": "on [fixed]",
"tx_checksum_ipv4": "off [fixed]",
"tx_checksum_ipv6": "off [fixed]",
"tx_checksum_sctp": "on [fixed]",
"tx_checksumming": "on",
"tx_esp_segmentation": "off [fixed]",
"tx_fcoe_segmentation": "off [fixed]",
"tx_gre_csum_segmentation": "off [fixed]",
"tx_gre_segmentation": "off [fixed]",
"tx_gso_list": "on",
"tx_gso_partial": "off [fixed]",
"tx_gso_robust": "off [fixed]",
"tx_ipxip4_segmentation": "off [fixed]",
"tx_ipxip6_segmentation": "off [fixed]",
"tx_nocache_copy": "off [fixed]",
"tx_scatter_gather": "on [fixed]",
"tx_scatter_gather_fraglist": "on [fixed]",
"tx_sctp_segmentation": "on",
"tx_tcp6_segmentation": "on",
"tx_tcp_accecn_segmentation": "on",
"tx_tcp_ecn_segmentation": "on",
"tx_tcp_mangleid_segmentation": "on",
"tx_tcp_segmentation": "on",
"tx_tunnel_remcsum_segmentation": "off [fixed]",
"tx_udp_segmentation": "on",
"tx_udp_tnl_csum_segmentation": "off [fixed]",
"tx_udp_tnl_segmentation": "off [fixed]",
"tx_vlan_offload": "off [fixed]",
"tx_vlan_stag_hw_insert": "off [fixed]",
"vlan_challenged": "on [fixed]"
},
"hw_timestamp_filters": [],
"ipv4": {
"address": "127.0.0.1",
"broadcast": "",
"netmask": "255.0.0.0",
"network": "127.0.0.0",
"prefix": "8"
},
"ipv6": [
{
"address": "::1",
"prefix": "128",
"scope": "host"
}
],
"mtu": 65536,
"promisc": false,
"timestamping": [],
"type": "loopback"
},
"ansible_loadavg": {
"15m": 0.1162109375,
"1m": 0.14208984375,
"5m": 0.16552734375
},
"ansible_local": {},
"ansible_locally_reachable_ips": {
"ipv4": [
"10.13.8.45",
"1.2.3.4",
"127.0.0.0/8",
"127.0.0.1"
],
"ipv6": [
"::1",
"1:2:3:4::beba:cafe",
"fe80::e0c3:aeff:fe14:34b",
"fe80::e0c3:aeff:fe14:6b3a",
"fe80::e0c3:aeff:fe14:d46b"
]
},
"ansible_lsb": {
"codename": "resolute",
"description": "Ubuntu 26.04 LTS",
"id": "Ubuntu",
"major_release": "26",
"release": "26.04"
},
"ansible_lvm": {
"lvs": {},
"pvs": {},
"vgs": {}
},
"ansible_machine": "x86_64",
"ansible_machine_id": "00873defdee14a61a13e76e821f5e4aa",
"ansible_memfree_mb": 944,
"ansible_memory_mb": {
"nocache": {
"free": 1545,
"used": 304
},
"real": {
"free": 944,
"total": 1849,
"used": 905
},
"swap": {
"cached": 0,
"free": 0,
"total": 0,
"used": 0
}
},
"ansible_memtotal_mb": 1849,
"ansible_mounts": [
{
"block_available": 4142506,
"block_size": 4096,
"block_total": 5135638,
"block_used": 993132,
"device": "/dev/vda2",
"dump": 0,
"fstype": "ext4",
"inode_available": 1198181,
"inode_total": 1308160,
"inode_used": 109979,
"mount": "/",
"options": "rw,relatime",
"passno": 0,
"size_available": 16967704576,
"size_total": 21035573248,
"uuid": "40d456dd-db46-48fa-ae40-844e2be77c66"
}
],
"ansible_nodename": "helio",
"ansible_os_family": "Debian",
"ansible_pkg_mgr": "apt",
"ansible_proc_cmdline": {
"BOOT_IMAGE": "/boot/vmlinuz-7.0.0-29-generic",
"biosdevname": "0",
"memhp_default_state": "online",
"net.ifnames": "0",
"ro": true,
"root": "UUID=40d456dd-db46-48fa-ae40-844e2be77c66"
},
"ansible_processor": [
"0",
"AuthenticAMD",
"AMD EPYC 7542 32-Core Processor"
],
"ansible_processor_cores": 1,
"ansible_processor_count": 1,
"ansible_processor_nproc": 1,
"ansible_processor_threads_per_core": 1,
"ansible_processor_vcpus": 1,
"ansible_product_name": "Cloud Server",
"ansible_product_serial": "NA",
"ansible_product_uuid": "00873def-dee1-4a61-a13e-76e821f5e4aa",
"ansible_product_version": "pc-i440fx-7.2",
"ansible_python": {
"executable": "/usr/bin/python3.14",
"has_sslcontext": true,
"type": "cpython",
"version": {
"major": 3,
"micro": 4,
"minor": 14,
"releaselevel": "final",
"serial": 0
},
"version_info": [
3,
14,
4,
"final",
0
]
},
"ansible_python_version": "3.14.4",
"ansible_real_group_id": 0,
"ansible_real_user_id": 0,
"ansible_selinux": {
"status": "disabled"
},
"ansible_selinux_python_present": true,
"ansible_service_mgr": "systemd",
"ansible_ssh_host_key_ecdsa_public": "ABC123=",
"ansible_ssh_host_key_ecdsa_public_keytype": "ecdsa-sha2-nistp256",
"ansible_ssh_host_key_ed25519_public": "ABC123",
"ansible_ssh_host_key_ed25519_public_keytype": "ssh-ed25519",
"ansible_ssh_host_key_rsa_public": "ABC123=",
"ansible_ssh_host_key_rsa_public_keytype": "ssh-rsa",
"ansible_swapfree_mb": 0,
"ansible_swaptotal_mb": 0,
"ansible_system": "Linux",
"ansible_system_capabilities": [],
"ansible_system_capabilities_enforced": "False",
"ansible_system_vendor": "UpCloud",
"ansible_systemd": {
"features": "+PAM +AUDIT +SELINUX +APPARMOR +IMA +IPE +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +BTF -XKBCOMMON -UTMP +SYSVINIT +LIBARCHIVE",
"version": 259
},
"ansible_uptime_seconds": 1340,
"ansible_user_dir": "/root",
"ansible_user_gecos": "root",
"ansible_user_gid": 0,
"ansible_user_id": "root",
"ansible_user_shell": "/bin/bash",
"ansible_user_uid": 0,
"ansible_userspace_architecture": "x86_64",
"ansible_userspace_bits": "64",
"ansible_virtualization_role": "NA",
"ansible_virtualization_tech_guest": [],
"ansible_virtualization_tech_host": [],
"ansible_virtualization_type": "NA",
"discovered_interpreter_python": "/usr/bin/python3.14",
"gather_subset": [
"all"
],
"module_setup": true
},
"changed": false
}
Abri um grupo novo, SRE - Site Reliability Engineer, e uma categoria nova sobre Ansible já que agora esse é meu mundo. Estou trabalhando nessa área mantendo servidores rodando na empresa nova.
Eu estou migrando um sistema que cria VMs de python, pela falta de suporte na biblioteca, pra outra forma via linha de comando. Mas essa parte não interessa muito. O interessante é sobre como fiz parte do trabalho.
E estou escrevendo a respeito porque foi difícil achar informação sobre isso na Internet. A maioria estava ou errada ou não funcionava como esperado.
Pra começar, vamos dar uma olhada na estrutura de dados que recebo do programa. Pra simular o mesmo no Ansible, vou trocar o comando por um: cat server.json (onde server.json contém esse dado). Meu objetivo aqui é pegar o IPv4 da interface pública pra depois provisionar o sistema com os programas que vamos usar.
{
"core_number": "1",
"hostname": "helio-testing.loureiro.eng.br",
"license": 0,
"memory_amount": "1024",
"plan": "1xCPU-1GB",
"progress": "0",
"state": "started",
"tags": [],
"title": "helio-testing.loureiro.eng.br (created via ansible)",
"uuid": "87271929-a137-4910-9648-75d05b6d3ecb",
"zone": "sweden-stockholm",
"boot_order": "disk",
"firewall": "off",
"host": 12345678,
"ip_addresses": [
{
"access": "internal",
"address": "192.168.0.1",
"family": "IPv4",
"part_of_plan": "no",
"ptr_record": "",
"server": "",
"mac": "",
"floating": "no",
"zone": ""
},
{
"access": "public",
"address": "1.2.3.4",
"family": "IPv4",
"part_of_plan": "yes",
"ptr_record": "",
"server": "",
"mac": "",
"floating": "no",
"zone": ""
}
],
"labels": {
"label": []
},
"metadata": "yes",
"nic_model": "virtio",
"networking": {
"interfaces": [
{
"index": 1,
"ip_addresses": [
{
"access": "",
"address": "1.2.3.4",
"family": "IPv4",
"part_of_plan": "no",
"ptr_record": "",
"server": "",
"mac": "",
"floating": "no",
"zone": ""
}
],
"mac": "a1:b2:c3:e4:f5:01",
"network": "fb29cb51-5dd7-4674-baac-b0253a725305",
"type": "public",
"bootable": "no",
"source_ip_filtering": "yes"
},
{
"index": 2,
"ip_addresses": [
{
"access": "",
"address": "192.168.0.1",
"family": "IPv4",
"part_of_plan": "no",
"ptr_record": "",
"server": "",
"mac": "",
"floating": "no",
"zone": ""
}
],
"mac": "a1:b2:c3:e4:f5:02",
"network": "92351420-66ec-46e9-98ee-149e3a588bdf",
"type": "utility",
"bootable": "no",
"source_ip_filtering": "yes"
}
]
},
"server_group": "",
"simple_backup": "no",
"storage_devices": [
{
"address": "virtio:0",
"storage": "fe128b6b-876c-4f7b-a070-3a8d6cec6159",
"storage_size": 10,
"storage_tier": "maxiops",
"storage_title": "helio-testing.loureiro.eng.br-OS",
"type": "disk",
"boot_disk": "0"
}
],
"timezone": "UTC",
"video_model": "vga",
"remote_access_enabled": "no",
"remote_access_type": "vnc",
"remote_access_host": "",
"remote_access_password": "abracadabra",
"remote_access_port": "0"
}
Então vamos começar com como pegar a saída desse comando no ansible. Pra isso basta chamar uma parte simples que registra o resultado.
---
- debug: msg="running the command and getting json as result"
- name: read json file
command: >
cat /tmp/server.json
register: result
failed_when: result.rc != 0
- debug:
msg="{{ result }}"
Não tem muito segredo aqui. Eu rodo o comando, que aqui eu troquei pelo cat e recebo o resultando em result. Eu olho se result.rc é diferente de zero pra saber se deu certo (não zero significa erro).
- name: parsing as json
set_fact:
json_result: "{{ result.stdout }}"
- debug:
msg=" from json_result "
msg="{{ json_result}}"
Aqui foi o primeiro pulo do gato. Pra receber o dado como json bastava só pegar de result.stdout. Em muitos lugares achei receitas exotéricas como {{ result | to_json }}. Todas erradas.
- name: getting IPs
set_fact:
json_ip_addresses: "{{ json_result.ip_addresses }}"
- debug: msg="{{ json_ip_addresses }}"
Do código json que recebo, eu filtro somente ip_addresses, que é a parte que me interessa.
- name: filtering public IPs
set_fact:
public_ip_addresses: "{{ json_ip_addresses | json_query(query) }}"
vars:
query: "[?access=='public']"
- debug: msg="{{ public_ip_addresses }}"
Em seguida eu aplico filtro de json usando a sintaxe de jpath. Na parte da query, que tem um array, eu quero somente aquela que tem a propriedade "access" com o valor "public". A query vai dentro de vars por causa das aspas simples e duplas.
- name: filtering IPv4 only
set_fact:
public_ipv4_address: "{{ public_ip_addresses | json_query(query) }}"
vars:
query: "[?family=='IPv4'].address"
- debug: msg="{{ public_ipv4_address }}"
No exemplo que tenho eu já não tenho mais nada, mas em alguns casos eu tenho um array com 2 elementos: IPv4 e IPv6. Então essa segunda query é pra filtrar qual estrutura tem a propriedade "family" com valor "IPv4". Dessa estrutura eu quero o valor de "address". E pronto! Está aí o IPv4 filtrado. O valor é 1.2.3.4, que é o esperado.
Agora rodando com Ansbile:
❯ ansible-playbook deploy.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [get JSON] ***************************************************************************************************************************************************************************
TASK [getjson : debug] ********************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "running from roles/getjson/tasks"
}
TASK [getjson : read json file] ***********************************************************************************************************************************************************
changed: [localhost]
TASK [getjson : debug] ********************************************************************************************************************************************************************
ok: [localhost] => {
"msg": {
"changed": true,
"cmd": [
"cat",
"../server.json"
],
"delta": "0:00:00.002636",
"end": "2024-11-23 16:02:30.099466",
"failed": false,
"failed_when_result": false,
"msg": "",
"rc": 0,
"start": "2024-11-23 16:02:30.096830",
"stderr": "",
"stderr_lines": [],
"stdout": "{\n \"core_number\": \"1\",\n \"hostname\": \"helio-testing.loureiro.eng.br\",\n \"license\": 0,\n \"memory_amount\": \"1024\",\n \"plan\": \"1xCPU-1GB\",\n \"progress\": \"0\",\n \"state\": \"started\",\n \"tags\": [],\n \"title\": \"helio-testing.loureiro.eng.br (created via ansible)\",\n \"uuid\": \"87271929-a137-4910-9648-75d05b6d3ecb\",\n \"zone\": \"sweden-stockholm\",\n \"boot_order\": \"disk\",\n \"firewall\": \"off\",\n \"host\": 12345678,\n \"ip_addresses\": [\n {\n \"access\": \"internal\",\n \"address\": \"192.168.0.1\",\n \"family\": \"IPv4\",\n \"part_of_plan\": \"no\",\n \"ptr_record\": \"\",\n \"server\": \"\",\n \"mac\": \"\",\n \"floating\": \"no\",\n \"zone\": \"\"\n },\n {\n \"access\": \"public\",\n \"address\": \"1.2.3.4\",\n \"family\": \"IPv4\",\n \"part_of_plan\": \"yes\",\n \"ptr_record\": \"\",\n \"server\": \"\",\n \"mac\": \"\",\n \"floating\": \"no\",\n \"zone\": \"\"\n }\n ],\n \"labels\": {\n \"label\": []\n },\n \"metadata\": \"yes\",\n \"nic_model\": \"virtio\",\n \"networking\": {\n \"interfaces\": [\n {\n \"index\": 1,\n \"ip_addresses\": [\n {\n \"access\": \"\",\n \"address\": \"1.2.3.4\",\n \"family\": \"IPv4\",\n \"part_of_plan\": \"no\",\n \"ptr_record\": \"\",\n \"server\": \"\",\n \"mac\": \"\",\n \"floating\": \"no\",\n \"zone\": \"\"\n }\n ],\n \"mac\": \"a1:b2:c3:e4:f5:01\",\n \"network\": \"fb29cb51-5dd7-4674-baac-b0253a725305\",\n \"type\": \"public\",\n \"bootable\": \"no\",\n \"source_ip_filtering\": \"yes\"\n },\n {\n \"index\": 2,\n \"ip_addresses\": [\n {\n \"access\": \"\",\n \"address\": \"192.168.0.1\",\n \"family\": \"IPv4\",\n \"part_of_plan\": \"no\",\n \"ptr_record\": \"\",\n \"server\": \"\",\n \"mac\": \"\",\n \"floating\": \"no\",\n \"zone\": \"\"\n }\n ],\n \"mac\": \"a1:b2:c3:e4:f5:02\",\n \"network\": \"92351420-66ec-46e9-98ee-149e3a588bdf\",\n \"type\": \"utility\",\n \"bootable\": \"no\",\n \"source_ip_filtering\": \"yes\"\n }\n ]\n },\n \"server_group\": \"\",\n \"simple_backup\": \"no\",\n \"storage_devices\": [\n {\n \"address\": \"virtio:0\",\n \"storage_encrypted\": \"yes\",\n \"part_of_plan\": \"\",\n \"storage\": \"fe128b6b-876c-4f7b-a070-3a8d6cec6159\",\n \"storage_size\": 50,\n \"storage_tier\": \"maxiops\",\n \"storage_title\": \"helio-testing.loureiro.eng.br-OS\",\n \"type\": \"disk\",\n \"boot_disk\": \"0\"\n }\n ],\n \"timezone\": \"UTC\",\n \"video_model\": \"vga\",\n \"remote_access_enabled\": \"no\",\n \"remote_access_type\": \"vnc\",\n \"remote_access_host\": \"\",\n \"remote_access_password\": \"abracadabra\",\n \"remote_access_port\": \"0\"\n}",
"stdout_lines": [
"{",
" \"core_number\": \"1\",",
" \"hostname\": \"helio-testing.loureiro.eng.br\",",
" \"license\": 0,",
" \"memory_amount\": \"1024\",",
" \"plan\": \"1xCPU-1GB\",",
" \"progress\": \"0\",",
" \"state\": \"started\",",
" \"tags\": [],",
" \"title\": \"helio-testing.loureiro.eng.br (created via ansible)\",",
" \"uuid\": \"87271929-a137-4910-9648-75d05b6d3ecb\",",
" \"zone\": \"sweden-stockholm\",",
" \"boot_order\": \"disk\",",
" \"firewall\": \"off\",",
" \"host\": 12345678,",
" \"ip_addresses\": [",
" {",
" \"access\": \"internal\",",
" \"address\": \"192.168.0.1\",",
" \"family\": \"IPv4\",",
" \"part_of_plan\": \"no\",",
" \"ptr_record\": \"\",",
" \"server\": \"\",",
" \"mac\": \"\",",
" \"floating\": \"no\",",
" \"zone\": \"\"",
" },",
" {",
" \"access\": \"public\",",
" \"address\": \"1.2.3.4\",",
" \"family\": \"IPv4\",",
" \"part_of_plan\": \"yes\",",
" \"ptr_record\": \"\",",
" \"server\": \"\",",
" \"mac\": \"\",",
" \"floating\": \"no\",",
" \"zone\": \"\"",
" }",
" ],",
" \"labels\": {",
" \"label\": []",
" },",
" \"metadata\": \"yes\",",
" \"nic_model\": \"virtio\",",
" \"networking\": {",
" \"interfaces\": [",
" {",
" \"index\": 1,",
" \"ip_addresses\": [",
" {",
" \"access\": \"\",",
" \"address\": \"1.2.3.4\",",
" \"family\": \"IPv4\",",
" \"part_of_plan\": \"no\",",
" \"ptr_record\": \"\",",
" \"server\": \"\",",
" \"mac\": \"\",",
" \"floating\": \"no\",",
" \"zone\": \"\"",
" }",
" ],",
" \"mac\": \"a1:b2:c3:e4:f5:01\",",
" \"network\": \"fb29cb51-5dd7-4674-baac-b0253a725305\",",
" \"type\": \"public\",",
" \"bootable\": \"no\",",
" \"source_ip_filtering\": \"yes\"",
" },",
" {",
" \"index\": 2,",
" \"ip_addresses\": [",
" {",
" \"access\": \"\",",
" \"address\": \"192.168.0.1\",",
" \"family\": \"IPv4\",",
" \"part_of_plan\": \"no\",",
" \"ptr_record\": \"\",",
" \"server\": \"\",",
" \"mac\": \"\",",
" \"floating\": \"no\",",
" \"zone\": \"\"",
" }",
" ],",
" \"mac\": \"a1:b2:c3:e4:f5:02\",",
" \"network\": \"92351420-66ec-46e9-98ee-149e3a588bdf\",",
" \"type\": \"utility\",",
" \"bootable\": \"no\",",
" \"source_ip_filtering\": \"yes\"",
" }",
" ]",
" },",
" \"server_group\": \"\",",
" \"simple_backup\": \"no\",",
" \"storage_devices\": [",
" {",
" \"address\": \"virtio:0\",",
" \"storage_encrypted\": \"yes\",",
" \"part_of_plan\": \"\",",
" \"storage\": \"fe128b6b-876c-4f7b-a070-3a8d6cec6159\",",
" \"storage_size\": 50,",
" \"storage_tier\": \"maxiops\",",
" \"storage_title\": \"helio-testing.loureiro.eng.br-OS\",",
" \"type\": \"disk\",",
" \"boot_disk\": \"0\"",
" }",
" ],",
" \"timezone\": \"UTC\",",
" \"video_model\": \"vga\",",
" \"remote_access_enabled\": \"no\",",
" \"remote_access_type\": \"vnc\",",
" \"remote_access_host\": \"\",",
" \"remote_access_password\": \"abracadabra\",",
" \"remote_access_port\": \"0\"",
"}"
]
}
}
TASK [getjson : parsing as json] **********************************************************************************************************************************************************
ok: [localhost]
TASK [getjson : debug] ********************************************************************************************************************************************************************
ok: [localhost] => {
"msg": {
"boot_order": "disk",
"core_number": "1",
"firewall": "off",
"host": 12345678,
"hostname": "helio-testing.loureiro.eng.br",
"ip_addresses": [
{
"access": "internal",
"address": "192.168.0.1",
"family": "IPv4",
"floating": "no",
"mac": "",
"part_of_plan": "no",
"ptr_record": "",
"server": "",
"zone": ""
},
{
"access": "public",
"address": "1.2.3.4",
"family": "IPv4",
"floating": "no",
"mac": "",
"part_of_plan": "yes",
"ptr_record": "",
"server": "",
"zone": ""
}
],
"labels": {
"label": []
},
"license": 0,
"memory_amount": "1024",
"metadata": "yes",
"networking": {
"interfaces": [
{
"bootable": "no",
"index": 1,
"ip_addresses": [
{
"access": "",
"address": "1.2.3.4",
"family": "IPv4",
"floating": "no",
"mac": "",
"part_of_plan": "no",
"ptr_record": "",
"server": "",
"zone": ""
}
],
"mac": "a1:b2:c3:e4:f5:01",
"network": "fb29cb51-5dd7-4674-baac-b0253a725305",
"source_ip_filtering": "yes",
"type": "public"
},
{
"bootable": "no",
"index": 2,
"ip_addresses": [
{
"access": "",
"address": "192.168.0.1",
"family": "IPv4",
"floating": "no",
"mac": "",
"part_of_plan": "no",
"ptr_record": "",
"server": "",
"zone": ""
}
],
"mac": "a1:b2:c3:e4:f5:02",
"network": "92351420-66ec-46e9-98ee-149e3a588bdf",
"source_ip_filtering": "yes",
"type": "utility"
}
]
},
"nic_model": "virtio",
"plan": "1xCPU-1GB",
"progress": "0",
"remote_access_enabled": "no",
"remote_access_host": "",
"remote_access_password": "abracadabra",
"remote_access_port": "0",
"remote_access_type": "vnc",
"server_group": "",
"simple_backup": "no",
"state": "started",
"storage_devices": [
{
"address": "virtio:0",
"boot_disk": "0",
"part_of_plan": "",
"storage": "fe128b6b-876c-4f7b-a070-3a8d6cec6159",
"storage_encrypted": "yes",
"storage_size": 50,
"storage_tier": "maxiops",
"storage_title": "helio-testing.loureiro.eng.br-OS",
"type": "disk"
}
],
"tags": [],
"timezone": "UTC",
"title": "helio-testing.loureiro.eng.br (created via ansible)",
"uuid": "87271929-a137-4910-9648-75d05b6d3ecb",
"video_model": "vga",
"zone": "sweden-stockholm"
}
}
TASK [getjson : getting IPs] **************************************************************************************************************************************************************
ok: [localhost]
TASK [getjson : debug] ********************************************************************************************************************************************************************
ok: [localhost] => {
"msg": [
{
"access": "internal",
"address": "192.168.0.1",
"family": "IPv4",
"floating": "no",
"mac": "",
"part_of_plan": "no",
"ptr_record": "",
"server": "",
"zone": ""
},
{
"access": "public",
"address": "1.2.3.4",
"family": "IPv4",
"floating": "no",
"mac": "",
"part_of_plan": "yes",
"ptr_record": "",
"server": "",
"zone": ""
}
]
}
TASK [getjson : filtering public IPs] *****************************************************************************************************************************************************
ok: [localhost]
TASK [getjson : debug] ********************************************************************************************************************************************************************
ok: [localhost] => {
"msg": [
{
"access": "public",
"address": "1.2.3.4",
"family": "IPv4",
"floating": "no",
"mac": "",
"part_of_plan": "yes",
"ptr_record": "",
"server": "",
"zone": ""
}
]
}
TASK [getjson : filtering IPv4 only] ******************************************************************************************************************************************************
ok: [localhost]
TASK [getjson : debug] ********************************************************************************************************************************************************************
ok: [localhost] => {
"msg": [
"1.2.3.4"
]
}
TASK [getjson : cloud server IP] ********************************************************************************************************************************************************
ok: [localhost]
TASK [getjson : debug] ********************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "1.2.3.4"
}
PLAY RECAP *********************************************************************************************************************************************************************************
localhost : ok=15 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Bom ansible and happy coding 😄