Bug #23936
closedAnsible Windows network facts fail to import
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