-
Bug
-
Resolution: Done
-
Major
-
6.16.0
-
3
-
False
-
foreman-3.15.0
-
sat-endeavour
-
None
-
None
-
None
-
Automated
-
Yes
Till Satellite 6.15, everything worked fine. Soon after upgrading to Satellite 6.16, We are not able to use the reports API within redhat.satellite.foreman plugin to fetch dynamic inventory from satellite.
Further investigation reveals that, "Ansible - Ansible Inventory" is not getting generated at all, when a registered host in satellite has the "Remote Execution" flag , unselected on it's primary interface.
How Reproducible:
100%
Is it a regression?
Yes, from 6.15
Steps to reproduce:
- Install a Satellite 6.16
- Register a system with satellite
- Edit the system from All hosts page, edit it's interfaces and unselect the Remote Execution option and then save
- Try to preview the "Ansible - Ansible Inventory" report template
- Try to generate a report from "Ansible - Ansible Inventory" report template
Actual Results:
Step 4 works.
On Step 5, the report generation fails:
2025-04-22T14:37:43 [E|app|11107e10] Error performing TemplateRenderJob (Job ID: 9a85199c-15f2-49a3-9a53-39cef1d040d1) from Dynflow(default) in 110.27ms: Safemode::NoMethodError (undefined method '#ip' for NilClass::Jail (NilClass)): 11107e10 | /usr/share/gems/gems/safemode-1.5.0/lib/safemode/jail.rb:22:in `method_missing' 11107e10 | Ansible - Ansible Inventory:118:in `block (2 levels) in initialize' 11107e10 | /usr/share/gems/gems/safemode-1.5.0/lib/safemode/jail.rb:31:in `each' 11107e10 | /usr/share/gems/gems/safemode-1.5.0/lib/safemode/jail.rb:31:in `find' 11107e10 | /usr/share/gems/gems/safemode-1.5.0/lib/safemode/jail.rb:31:in `method_missing' 11107e10 | Ansible - Ansible Inventory:118:in `block in initialize'
Verified that there's at least one system present which matches the condition of having no REX interface.
# cat << EOF | foreman-rake console conf.echo = false Host.all.each do |h| pp h.name if h.execution_interface.nil? end EOF Loading production environment (Rails 6.1.7.8) Switch to inspect mode. conf.echo = false Host.all.each do |h| pp h.name if h.execution_interface.nil? end "mysystem.example.com"
Expected Results:
Having Remote Execution option unselected for an interface, should not serve as a blocker for this report generation ( or the usage of redhat.satellite.foreman inventory plugin )
Additional Information:
It seems the error is hitting at this place https://github.com/theforeman/foreman/blob/develop/app/views/unattended/report_templates/ansible_-_ansible_inventory.erb#L178-L189
```
net_sources = [host] net_sources.unshift(host.execution_interface) if host.respond_to?(:execution_interface) if input_ipv4 || input_subnet ipv4_source = net_sources.find { |s| s.ip } inventory_data.update('ipv4': ipv4_source&.ip) if input_ipv4 inventory_data.update('subnet': ipv4_source&.subnet) if input_subnet end
```
I am guessing:
- There is a host and that host responds to host.execution_interface call
- Perhaps host.execution_interface returns nil
- nil is added to the array (via unshift)
- And then when "ipv4_source = net_sources.find { |s| s.ip }" is happening, it's trying work on nil data and s.ip part errors out with that "undefined method '#ip' for NilClass"
For the affected system:
irb(main):005:0> h.execution_interface
=> nil
irb(main):006:0> h.respond_to?(:execution_interface)
=> true
So that means, there is a host present, whose Remote Execution option is unselected in it's interface of satellite.
I believe https://github.com/theforeman/foreman/commit/c75c51b0fc8ac450f3a4cbd23ce334ff782c1a46 is what brought in the change as we added this in foreman 3.11 and Satellite 6.15 was using 3.9 ( a older version ).
- is cloned by
-
SAT-34208 undefined method '#ip' for NilClass when trying to generate "Ansible - Ansible Inventory" report in Satellite 6.16 or later
-
- Closed
-
- links to