Project

General

Profile

Bug #35658

Ansible fact parser fails to parse Windows facts if they do not contain os_name

Added by Evgeni Golov about 2 months ago. Updated 8 days ago.

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

Description

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

Log:

2022-10-20T13:23:51 [I|app|d3408894] Started POST "/api/v2/hosts/facts" for 192.168.1.90 at 2022-10-20 13:23:51 +0200
2022-10-20T13:23:51 [I|app|d3408894] Processing by Api::V2::HostsController#facts as JSON
2022-10-20T13:23:51 [I|app|d3408894]   Parameters: {"name"=>"win10test002.testdom.local", "facts"=>"[FILTERED]", "apiv"=>"v2", "host"=>{"name"=>"win10test002.testdom.local"}}
2022-10-20T13:23:52 [I|app|d3408894] Import facts for 'win10test002.testdom.local' completed. Added: 100, Updated: 0, Deleted 0 facts
2022-10-20T13:23:52 [W|app|d3408894] Action failed
2022-10-20T13:23:52 [I|app|d3408894] Backtrace for 'Action failed' error (NoMethodError): undefined method `tr' for nil:NilClass
 d3408894 | Did you mean?  try
 d3408894 | /usr/share/foreman/app/services/foreman_ansible/operating_system_parser.rb:82:in `os_name'
 d3408894 | /usr/share/foreman/app/services/foreman_ansible/operating_system_parser.rb:7:in `operatingsystem'

The problem is that Ansible does not report the `ansible_os_name` and `ansible_distribution` facts when executed without Admin privileges (see https://github.com/ansible-collections/ansible.windows/pull/78 and https://github.com/ansible-collections/ansible.windows/issues/389 for details, but the issue existed before the PR too, just less obviously).

Associated revisions

Revision 02ea67ce (diff)
Added by Evgeni Golov about 2 months ago

Fixes #35658 - don't fail parsing Windows facts without os_name

When Ansible runs on Windows without Admin privileges, it will not
report `ansible_os_name` and `ansible_distribution` facts, as those
can't be read without being Admin. Don't fail to parse facts in this
case and fall back to a generic "Microsoft Windows" name.

History

#1 Updated by The Foreman Bot about 2 months ago

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

#2 Updated by The Foreman Bot about 2 months ago

  • Fixed in Releases 3.5.0 added

#3 Updated by Evgeni Golov about 2 months ago

  • Status changed from Ready For Testing to Closed

#4 Updated by Ewoud Kohl van Wijngaarden 8 days ago

  • Triaged changed from No to Yes

Also available in: Atom PDF