Project

General

Profile

Bug #23936

Ansible Windows network facts fail to import

Added by Joop van de Wege about 4 years ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Category:
Facts
Target version:
-
Difficulty:
Triaged:
Yes
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

It looks like the facts returned from ansible -m setup for Windows hosts contain a different structure which foreman_ansible can't handle at the moment.
Foreman-1.17.1
tfm-rubygem-foreman_ansible-2.0.1-1.fm1_17.el7.noarch
tfm-rubygem-foreman_ansible_core-2.0.2-1.fm1_17.el7.noarch

Part of the production.log:
2018-06-14T13:30:50 789f63be [app] [I] Import facts for 'win01' completed. Added: 94, Updated: 0, Deleted 0 facts
2018-06-14T13:30:50 789f63be [app] [D] ANSIBLE os_name fact: 'MicrosoftWindowsServer2016StandardEvaluation'
2018-06-14T13:30:50 789f63be [app] [D] INTERFACE with identifier '[{"macaddress"=>"00:1A:4A:16:01:09", "default_gateway"=>"192.168.0.252", "connection_name
"=>"Ethernet", "dns_domain"=>"bit.nl", "interface_name"=>"Red Hat VirtIO Ethernet Adapter", "interface_index"=>5}]'
2018-06-14T13:30:50 789f63be [app] [W] Action failed | NoMethodError: undefined method `downcase' for #<ActiveSupport::HashWithIndifferentAccess:0x00007f99bbb266f8> | /usr/share/foreman/app/services/fact_parser.rb:181:in `map' | /usr/share/foreman/app/services/fact_parser.rb:181:in `normalize_interfaces' | /usr/share/foreman/app/services/fact_parser.rb:67:in `interfaces' | /usr/share/foreman/app/services/fact_parser.rb:82:in `suggested_primary_interface' | /usr/share/foreman/app/models/host/base.rb:193:in `set_interfaces' | /usr/share/foreman/app/models/host/base.rb:178:in `populate_fields_from_facts' | /usr/share/foreman/app/models/host/managed.rb:372:in `populate_fields_from_facts' | /usr/share/foreman/app/models/concerns/puppet_host_extensions.rb:3:in `populate_fields_from_facts' | /usr/share/foreman/app/models/host/base.rb:157:in `parse_facts' | /usr/share/foreman/app/models/host/base.rb:146:in `import_facts' | /usr/share/foreman/app/models/host/managed.rb:298:in `import_facts' | /usr/share/foreman/app/controllers/api/v2/hosts_controller.rb:286:in `facts'

Part of the facts returned by ansible -m setup
"ansible_interfaces": [ {
"connection_name": "Ethernet",
"default_gateway": "192.168.0.252",
"dns_domain": "foo.bar",
"interface_index": 5,
"interface_name": "Red Hat VirtIO Ethernet Adapter",
"macaddress": "00:1A:4A:16:01:09"
}
],
"ansible_ip_addresses": [
"192.168.0.161",
"fe80::700f:67a2:7965:2fa0",
"2001:7b8:3:1000:700f:67a2:7965:2fa0"
],

which is quite different from the linux version.

Both the debug loglines with ANSIBLE/INTERFACE are extra debug lines I inserted in some ruby files in app/services/foreman_ansible to locate the problem.
I also applied, but that should be obvious from the log, the changes from https://github.com/theforeman/foreman_ansible/pull/178


Related issues

Related to Ansible - Bug #28088: Solaris network facts fail to parse by defaultNew

Associated revisions

Revision 8fa4f74b (diff)
Added by Lukáš Zapletal 10 months ago

Refs #23936 - disable NIC fact parsing on Windows

History

#1 Updated by Daniel Lobato Garcia about 4 years ago

Would you be OK with your interfaces having names like "Red Hat VirtIO Ethernet Adapter 5". Asking because as you say, in Linux, it's quite different. We may have

"ansible_interfaces": [ "lo", "eth0" ]
"ansible_eth0": {
            "active": true,
            "device": "eth0",
            "features": {
                "busy_poll": "off [fixed]",
                "fcoe_mtu": "off [fixed]",
                "generic_receive_offload": "on",
                "generic_segmentation_offload": "off [requested on]",
                "highdma": "on [fixed]",
                "hw_tc_offload": "off [fixed]",
                "l2_fwd_offload": "off [fixed]",
                "large_receive_offload": "off [fixed]",
                "loopback": "off [fixed]",
                "netns_local": "off [fixed]",
                "ntuple_filters": "off [fixed]",
                "receive_hashing": "off [fixed]",
                "rx_all": "off [fixed]",
                "rx_checksumming": "on",
                "rx_fcs": "off [fixed]",
                "rx_vlan_filter": "off [fixed]",
                "rx_vlan_offload": "on",
                "rx_vlan_stag_filter": "off [fixed]",
                "rx_vlan_stag_hw_parse": "off [fixed]",
                "scatter_gather": "off",
                "tcp_segmentation_offload": "off",
                "tx_checksum_fcoe_crc": "off [fixed]",
                "tx_checksum_ip_generic": "off [fixed]",
                "tx_checksum_ipv4": "off",
                "tx_checksum_ipv6": "off [fixed]",
                "tx_checksum_sctp": "off [fixed]",
                "tx_checksumming": "off",
                "tx_fcoe_segmentation": "off [fixed]",
                "tx_gre_csum_segmentation": "off [fixed]",
                "tx_gre_segmentation": "off [fixed]",
                "tx_gso_partial": "off [fixed]",
                "tx_gso_robust": "off [fixed]",
                "tx_ipip_segmentation": "off [fixed]",
                "tx_lockless": "off [fixed]",
                "tx_mpls_segmentation": "off [fixed]",
                "tx_nocache_copy": "off",
                "tx_scatter_gather": "off",
                "tx_scatter_gather_fraglist": "off [fixed]",
                "tx_sctp_segmentation": "off [fixed]",
                "tx_sit_segmentation": "off [fixed]",
                "tx_tcp6_segmentation": "off [fixed]",
                "tx_tcp_ecn_segmentation": "off [fixed]",
                "tx_tcp_mangleid_segmentation": "off",
                "tx_tcp_segmentation": "off",
                "tx_udp_tnl_csum_segmentation": "off [fixed]",
                "tx_udp_tnl_segmentation": "off [fixed]",
                "tx_vlan_offload": "on",
                "tx_vlan_stag_hw_insert": "off [fixed]",
                "udp_fragmentation_offload": "off [fixed]",
                "vlan_challenged": "off [fixed]" 
            },
            "hw_timestamp_filters": [],
            "ipv4": {
                "address": "192.168.121.27",
                "broadcast": "192.168.121.255",
                "netmask": "255.255.255.0",
                "network": "192.168.121.0" 
            },
            "ipv6": [
                {
                    "address": "fe80::5054:ff:fe30:e5ab",
                    "prefix": "64",
                    "scope": "link" 
                }
            ],
            "macaddress": "52:54:00:30:e5:ab",
            "module": "8139cp",
            "mtu": 1500,
            "pciid": "0000:00:03.0",
            "promisc": false,
            "speed": 100,
            "timestamping": [
                "rx_software",
                "software" 
            ],
            "type": "ether" 
        }

As far as I understand from your facts, all of these are IPs for "Red Hat VirtIO Ethernet Adapter 5"?

"ansible_ip_addresses": [
"192.168.0.161",
"fe80::700f:67a2:7965:2fa0",
"2001:7b8:3:1000:700f:67a2:7965:2fa0" 
]

Do you have a fact "ansible_domain" too?

#2 Updated by Joop van de Wege about 4 years ago

oot@vm01 log]# ansible windows -m setup  -i /root/hosts.ceph 
win01 | SUCCESS => {
    "ansible_facts": {
        "ansible_architecture": "64-bit", 
        "ansible_bios_date": "03/31/2014", 
        "ansible_bios_version": "1.11.0-2.el7", 
        "ansible_date_time": {
            "date": "2018-06-14", 
            "day": "14", 
            "epoch": "1528963719.52684", 
            "hour": "08", 
            "iso8601": "2018-06-14T15:08:39Z", 
            "iso8601_basic": "20180614T080839526842", 
            "iso8601_basic_short": "20180614T080839", 
            "iso8601_micro": "2018-06-14T15:08:39.526842Z", 
            "minute": "08", 
            "month": "06", 
            "second": "39", 
            "time": "08:08:39", 
            "tz": "Pacific Standard Time", 
            "tz_offset": "-07:00", 
            "weekday": "Thursday", 
            "weekday_number": "4", 
            "weeknumber": "23", 
            "year": "2018" 
        }, 
        "ansible_distribution": "Microsoft Windows Server 2016 Standard Evaluation", 
        "ansible_distribution_major_version": "10", 
        "ansible_distribution_version": "10.0.14393.0", 
        "ansible_domain": "", 
        "ansible_env": {
            "ALLUSERSPROFILE": "C:\\ProgramData", 
            "APPDATA": "C:\\Users\\Administrator\\AppData\\Roaming", 
            "COMPUTERNAME": "WIN-R4GM9HJH13C", 
            "ComSpec": "C:\\Windows\\system32\\cmd.exe", 
            "CommonProgramFiles": "C:\\Program Files\\Common Files", 
            "CommonProgramFiles(x86)": "C:\\Program Files (x86)\\Common Files", 
            "CommonProgramW6432": "C:\\Program Files\\Common Files", 
            "HOMEDRIVE": "C:", 
            "HOMEPATH": "\\Users\\Administrator", 
            "LOCALAPPDATA": "C:\\Users\\Administrator\\AppData\\Local", 
            "LOGONSERVER": "\\\\WIN-R4GM9HJH13C", 
            "NUMBER_OF_PROCESSORS": "1", 
            "OS": "Windows_NT", 
            "PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL", 
            "PROCESSOR_ARCHITECTURE": "AMD64", 
            "PROCESSOR_IDENTIFIER": "Intel64 Family 6 Model 61 Stepping 2, GenuineIntel", 
            "PROCESSOR_LEVEL": "6", 
            "PROCESSOR_REVISION": "3d02", 
            "PROMPT": "$P$G", 
            "PSExecutionPolicyPreference": "Unrestricted", 
            "PSModulePath": "C:\\Users\\Administrator\\Documents\\WindowsPowerShell\\Modules;C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules", 
            "PUBLIC": "C:\\Users\\Public", 
            "Path": "C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\WindowsApps", 
            "ProgramData": "C:\\ProgramData", 
            "ProgramFiles": "C:\\Program Files", 
            "ProgramFiles(x86)": "C:\\Program Files (x86)", 
            "ProgramW6432": "C:\\Program Files", 
            "SystemDrive": "C:", 
            "SystemRoot": "C:\\Windows", 
            "TEMP": "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp", 
            "TMP": "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp", 
            "USERDOMAIN": "WIN-R4GM9HJH13C", 
            "USERDOMAIN_ROAMINGPROFILE": "WIN-R4GM9HJH13C", 
            "USERNAME": "Administrator", 
            "USERPROFILE": "C:\\Users\\Administrator", 
            "windir": "C:\\Windows" 
        }, 
        "ansible_fqdn": "WIN-R4GM9HJH13C.", 
        "ansible_hostname": "WIN-R4GM9HJH13C", 
        "ansible_interfaces": [
            {
                "connection_name": "Ethernet", 
                "default_gateway": "192.168.0.252", 
                "dns_domain": "foo.bar", 
                "interface_index": 5, 
                "interface_name": "Red Hat VirtIO Ethernet Adapter", 
                "macaddress": "00:1A:4A:16:01:09" 
            }
        ], 
        "ansible_ip_addresses": [
            "192.168.0.161", 
            "fe80::700f:67a2:7965:2fa0", 
            "2001:7b8:3:1000:700f:67a2:7965:2fa0" 
        ], 
        "ansible_kernel": "10.0.14393.0", 
        "ansible_lastboot": "2018-06-14 04:22:31Z", 
        "ansible_machine_id": "S-1-5-21-3306178510-2233780695-579177611", 
        "ansible_memtotal_mb": 1023, 
        "ansible_nodename": "WIN-R4GM9HJH13C.", 
        "ansible_os_family": "Windows", 
        "ansible_os_name": "Microsoft Windows Server 2016 Standard Evaluation", 
        "ansible_owner_contact": "", 
        "ansible_owner_name": "Windows User", 
        "ansible_powershell_version": 5, 
        "ansible_processor": [
            "GenuineIntel", 
            "Intel Core Processor (Broadwell)" 
        ], 
        "ansible_processor_cores": 1, 
        "ansible_processor_count": 1, 
        "ansible_processor_threads_per_core": 1, 
        "ansible_processor_vcpus": 1, 
        "ansible_product_name": "oVirt Node", 
        "ansible_product_serial": "DEB2740A-0A48-11E8-9BB7-901B0EF8E955", 
        "ansible_reboot_pending": false, 
        "ansible_swaptotal_mb": 0, 
        "ansible_system": "Win32NT", 
        "ansible_system_description": "", 
        "ansible_system_vendor": "oVirt", 
        "ansible_uptime_seconds": 13570, 
        "ansible_user_dir": "C:\\Users\\Administrator", 
        "ansible_user_gecos": "", 
        "ansible_user_id": "Administrator", 
        "ansible_user_sid": "S-1-5-21-3306178510-2233780695-579177611-500", 
        "ansible_win_rm_certificate_expires": "2021-06-09 01:33:12", 
        "ansible_windows_domain": "WORKGROUP", 
        "ansible_windows_domain_member": false, 
        "ansible_windows_domain_role": "Stand-alone server", 
        "gather_subset": [
            "all" 
        ], 
        "module_setup": true
    }, 
    "changed": false
}
500 Server Error: Internal Server Error
[root@vm01 log]# 

These are the facts that ansible -m setup produces. I don't mind the naming of the nic because thats changable in Windows.

#3 Updated by wow berk almost 3 years ago

I have the same problem, it only works for me if I use:

ansible -m setup -i hosts_pre -a 'gather_subset=!network'

#4 Updated by Ondřej Ezr over 1 year ago

  • Triaged changed from No to Yes
  • Subject changed from Ansible Windows network facts to Ansible Windows network facts fail to import

#5 Updated by Ondřej Ezr over 1 year ago

  • Related to Bug #28088: Solaris network facts fail to parse by default added

#6 Updated by Lukas Zapletal 10 months ago

Further discussion:

https://community.theforeman.org/t/ansible-callback-with-windows-openssh-server-produces-a-500-server-error-internal/25689

I am going to propose to disable fact NIC parsing of Windows for now until we fully implement this.

#7 Updated by Lukas Zapletal 10 months ago

  • Assignee set to Lukas Zapletal
  • Category set to Facts
  • Project changed from Ansible to Foreman

#8 Updated by The Foreman Bot 10 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/8848 added

#9 Updated by The Foreman Bot 10 months ago

  • Fixed in Releases 3.1.0 added

#10 Updated by Amit Upadhye 8 months ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF