Unable to assigne ansible Roles to Host / Hostgroups

Problem:
Can not assign roles to hosts / hostgroups. Seems like the view is broken. The list is empty.

Expected outcome:
Assign roles to hosts

Foreman and Proxy versions:
1.21.2

Foreman and Proxy plugin versions:
rubygem-smart_proxy_ansible-2.1.2-1.fm1_21.el7.noarch
tfm-rubygem-foreman_ansible-2.3.3-1.fm1_21.el7.noarch
tfm-rubygem-foreman_ansible_core-2.2.0-1.fm1_21.el7.noarch

Other relevant data:
2019-04-15T10:44:59 [I|app|b223de93] Rendering hostgroups/edit.html.erb within
layouts/application
2019-04-15T10:44:59 [I|app|b223de93] ESC[1;32mDeface: [WARNING]ESC[0m No :origin
al defined for ‘hostgroup_ansible_roles_tab’, you should change its definition t
o include:
:original => ‘a428ce0f87a47c79e5b57992242203dce92baf92’
2019-04-15T10:44:59 [I|app|b223de93] ESC[1;32mDeface: [WARNING]ESC[0m No :origin
al defined for ‘hostgroup_ansible_roles_tab_content’, you should change its defi
nition to include:
:original => ‘ca14605833a3ba937e719456e983639c9500206e’

I’m having the same issue apparently.

I’ve been working towards implementing Foreman/Katello as a Spacewalk/RHSat5 replacement, with the expected nuke it from orbit, burn it down, stir the ashes, pave it over and rebuild on a fairly regular basis. Since last week, I’ve discovered this on 2 separate hosts, one in the office and one at home. Both are built on CentOS 7.6.1810, fully patched, as well as the current shipping version of Foreman and the Katello plugin.

foreman-release-1.21.2-1.el7.noarch
katello-3.11.0-1.el7.noarch

The following options were used on the foreman-installer command line:
–scenario=katello
–enable-foreman
–enable-foreman-plugin-ansible
–enable-foreman-proxy-plugin-ansible
–enable-foreman-plugin-setup
–enable-foreman-plugin-tasks
–enable-foreman-plugin-templates
–enable-foreman-proxy
–enable-foreman-plugin-bootdisk
–enable-katello
–enable-foreman-compute-vmware

From /var/log/foreman/production.log (this seems to be interesting or applies:)

2019-04-15T13:54:14 [I|app|e2940a57] Authorized user admin(Admin User)
2019-04-15T13:54:14 [I|app|e2940a57] Current user set to admin (admin)
2019-04-15T13:54:14 [W|app|e2940a57] Action failed
RuntimeError: Association not found for location
/usr/share/foreman/app/controllers/api/base_controller.rb:75:in `parent_scope'
/usr/share/foreman/app/controllers/api/base_controller.rb:61:in `resource_scope'
/usr/share/foreman/app/controllers/api/base_controller.rb:100:in `resource_scope_for_index'

Running ‘hammer -d ansible roles list’ yields (in part at least:)

[DEBUG 2019-04-15T14:05:04 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[ERROR 2019-04-15T14:05:04 API] 500 Internal Server Error
[DEBUG 2019-04-15T14:05:04 API] {
    "error" => {
        "message" => "Association not found for location"
    }
}
[DEBUG 2019-04-15T14:05:04 Exception] Using exception handler HammerCLIForeman::ExceptionHandler#handle_internal_error
[ERROR 2019-04-15T14:05:04 Exception] Association not found for location
Association not found for location
[ERROR 2019-04-15T14:05:04 Exception] 

As a rookie, I’m going to assume that there’s a log (or more) that I can inspect.

Additionally, I don’t see where/how to connect an Ansible role to a specific location or organization, they would appear to be neutral in that regard.

I should point out that Configure/Ansible/Roles in the browser GUI does show the very simple playbook that I’ve imported. ‘hammer ansible roles list’ does not list it at the commandline, and returns the error message buried in the debug output I pasted in.

Thanks for reporting this, I’ll take a look if I can reproduce somehow. @jkalchik, there should be something in /var/log/foreman/production.log related to this error.

1 Like

Hi @Ondrej_Prazak,

thank you for having a look. Seems like there is something wrong with deface as my log already showed. If you can not reproduce, just get in contact with me if i can help …

2019-04-16T08:43:50 [I|app|9cfd590f] Current user set to admin (admin)
2019-04-16T08:43:50 [D|app|9cfd590f] Current location set to Default Location
2019-04-16T08:43:50 [D|app|9cfd590f] Current organization set to Default Organization
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendering hosts/edit.html.erb within layouts/application
2019-04-16T08:43:51 [D|app|9cfd590f] ESC[1;32mDeface:ESC[0m 3 overrides found for 'hosts/_form'
2019-04-16T08:43:51 [D|app|9cfd590f] ESC[1;32mDeface:ESC[0m 'add_execution_interface_js' matched 1 times with 'div#primary'
2019-04-16T08:43:51 [I|app|9cfd590f] ESC[1;32mDeface: [WARNING]ESC[0m No :original defined for 'add_execution_interface_js', you should change its definition to include:
 :original => '738d75b8975dc598101e60505810ef267e2c43ae'
2019-04-16T08:43:51 [D|app|9cfd590f] ESC[1;32mDeface:ESC[0m 'ansible_roles_tab' matched 1 times with 'li.active'
2019-04-16T08:43:51 [I|app|9cfd590f] ESC[1;32mDeface: [WARNING]ESC[0m No :original defined for 'ansible_roles_tab', you should change its definition to include:
 :original => '8c63c5282ee199068bfd65475e13066ee981089a'
2019-04-16T08:43:51 [D|app|9cfd590f] ESC[1;32mDeface:ESC[0m 'ansible_roles_tab_content' matched 1 times with 'div.tab-pane.active'
2019-04-16T08:43:51 [I|app|9cfd590f] ESC[1;32mDeface: [WARNING]ESC[0m No :original defined for 'ansible_roles_tab_content', you should change its definition to include:
 :original => '738d75b8975dc598101e60505810ef267e2c43ae'
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered hosts/_progress.html.erb (1.3ms)
2019-04-16T08:43:51 [D|app|9cfd590f] Current organization set to Default Organization
2019-04-16T08:43:51 [D|app|9cfd590f] Current location set to Default Location
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered hosts/puppet/_main_tab_fields.html.erb (15.0ms)
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered collection of puppetclasses/_selectedClasses.html.erb [0 times] (0.1ms)
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered collection of puppetclasses/_classes_in_groups.html.erb [0 times] (0.0ms)
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered puppetclasses/_classes.html.erb (1.8ms)
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered puppetclasses/_class_selection.html.erb (70.2ms)
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered hosts/puppet/_puppet_classes_tab.html.erb (75.1ms)
2019-04-16T08:43:51 [D|app|9cfd590f] ESC[1;32mDeface:ESC[0m 1 overrides found for 'nic/_base_form'
2019-04-16T08:43:51 [D|app|9cfd590f] ESC[1;32mDeface:ESC[0m 'add_execution_interface' matched 1 times with 'erb[loud]:contains("interface_provision")'
2019-04-16T08:43:51 [I|app|9cfd590f] ESC[1;32mDeface: [WARNING]ESC[0m No :original defined for 'add_execution_interface', you should change its definition to include:
 :original => 'dbe1da973bfb251a74b994e7ae11bc8d11502c97'
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered nic/_base_form.html.erb (213.0ms)
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered nic/_virtual_form.html.erb (4.0ms)
2019-04-16T08:43:51 [D|app|9cfd590f] Reading from compute resource cache: networks
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered compute_resources_vms/form/vmware/_network.html.erb (4.1ms)
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered nic/_provider_specific_form.html.erb (8.6ms)
2019-04-16T08:43:51 [I|app|9cfd590f]   Rendered nic/manageds/_managed.html.erb (251.2ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered nic/_base_form.html.erb (145.4ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered nic/_virtual_form.html.erb (2.1ms)
2019-04-16T08:43:52 [D|app|9cfd590f] Reading from compute resource cache: networks
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered compute_resources_vms/form/vmware/_network.html.erb (1.9ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered nic/_provider_specific_form.html.erb (3.1ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered nic/manageds/_managed.html.erb (156.2ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered hosts/_interfaces.html.erb (415.5ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered collection of puppetclasses/_class_parameters.html.erb [0 times] (0.0ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered puppetclasses/_classes_parameters.html.erb (20.2ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered common_parameters/_inherited_parameters.html.erb (1.9ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered common_parameters/_parameter.html.erb (4.4ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered common_parameters/_parameters.html.erb (42.6ms)
2019-04-16T08:43:52 [D|app|9cfd590f] Current location set to Default Location
2019-04-16T08:43:52 [D|app|9cfd590f] Current organization set to Default Organization
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered hosts/_form.html.erb (962.4ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered hosts/edit.html.erb within layouts/application (1106.3ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered layouts/_application_content.html.erb (2.0ms)
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendering layouts/base.html.erb
2019-04-16T08:43:52 [I|app|9cfd590f]   Rendered layouts/base.html.erb (59.2ms)
2019-04-16T08:43:52 [I|app|9cfd590f] Completed 200 OK in 1478ms (Views: 1029.9ms | ActiveRecord: 205.5ms)
2019-04-16T08:43:52 [I|app|9f8f19ef] Started GET "/hosts/daten.storp.lab/edit" for 192.168.123.207 at 2019-04-16 08:43:52 +0200
2019-04-16T08:43:52 [I|app|9f8f19ef] Processing by HostsController#edit as HTML
2019-04-16T08:43:52 [I|app|9f8f19ef]   Parameters: {"id"=>"daten.storp.lab"}
2019-04-16T08:43:52 [I|app|9f8f19ef] Current user set to admin (admin)
2019-04-16T08:43:52 [D|app|9f8f19ef] Current location set to Default Location
2019-04-16T08:43:52 [D|app|9f8f19ef] Current organization set to Default Organization
2019-04-16T08:43:52 [I|app|9f8f19ef]   Rendering hosts/edit.html.erb within layouts/application
2019-04-16T08:43:52 [D|app|9f8f19ef] ESC[1;32mDeface:ESC[0m 3 overrides found for 'hosts/_form'
2019-04-16T08:43:52 [D|app|9f8f19ef] ESC[1;32mDeface:ESC[0m 'add_execution_interface_js' matched 1 times with 'div#primary'
2019-04-16T08:43:52 [I|app|9f8f19ef] ESC[1;32mDeface: [WARNING]ESC[0m No :original defined for 'add_execution_interface_js', you should change its definition to include:
 :original => '738d75b8975dc598101e60505810ef267e2c43ae'
2019-04-16T08:43:52 [D|app|9f8f19ef] ESC[1;32mDeface:ESC[0m 'ansible_roles_tab' matched 1 times with 'li.active'
2019-04-16T08:43:52 [I|app|9f8f19ef] ESC[1;32mDeface: [WARNING]ESC[0m No :original defined for 'ansible_roles_tab', you should change its definition to include:
 :original => '8c63c5282ee199068bfd65475e13066ee981089a'
2019-04-16T08:43:52 [D|app|9f8f19ef] ESC[1;32mDeface:ESC[0m 'ansible_roles_tab_content' matched 1 times with 'div.tab-pane.active'
2019-04-16T08:43:52 [I|app|9f8f19ef] ESC[1;32mDeface: [WARNING]ESC[0m No :original defined for 'ansible_roles_tab_content', you should change its definition to include:
 :original => '738d75b8975dc598101e60505810ef267e2c43ae'
2019-04-16T08:43:52 [I|app|9f8f19ef]   Rendered hosts/_progress.html.erb (1.3ms)
2019-04-16T08:43:52 [D|app|9f8f19ef] Current organization set to Default Organization
2019-04-16T08:43:52 [D|app|9f8f19ef] Current location set to Default Location
2019-04-16T08:43:52 [I|app|9f8f19ef]   Rendered hosts/puppet/_main_tab_fields.html.erb (15.5ms)
2019-04-16T08:43:52 [I|app|9f8f19ef]   Rendered collection of puppetclasses/_selectedClasses.html.erb [0 times] (0.0ms)
2019-04-16T08:43:52 [I|app|9f8f19ef]   Rendered collection of puppetclasses/_classes_in_groups.html.erb [0 times] (0.0ms)
2019-04-16T08:43:52 [I|app|9f8f19ef]   Rendered puppetclasses/_classes.html.erb (1.5ms)
2019-04-16T08:43:52 [I|app|9f8f19ef]   Rendered puppetclasses/_class_selection.html.erb (36.7ms)
2019-04-16T08:43:52 [I|app|9f8f19ef]   Rendered hosts/puppet/_puppet_classes_tab.html.erb (39.2ms)
2019-04-16T08:43:52 [D|app|9f8f19ef] ESC[1;32mDeface:ESC[0m 1 overrides found for 'nic/_base_form'
2019-04-16T08:43:52 [D|app|9f8f19ef] ESC[1;32mDeface:ESC[0m 'add_execution_interface' matched 1 times with 'erb[loud]:contains("interface_provision")'
2019-04-16T08:43:52 [I|app|9f8f19ef] ESC[1;32mDeface: [WARNING]ESC[0m No :original defined for 'add_execution_interface', you should change its definition to include:
 :original => 'dbe1da973bfb251a74b994e7ae11bc8d11502c97'

Thanks,
Bastian

@Ondrej_Prazak, I posted up a half a dozen lines from /var/log/foreman/production.log in my initial report. I can send/pastebin the entire section of log file that pertains if it would help (or you’d like.)

Thanks for looking into this.

I managed to reproduce, the ‘Ansible Roles’ tab was empty when creating a new host. But after I created a host and tried to edit it, the tab displayed correctly:

After that, it worked fine even when creating a new host.

I am not sure what is going on there, I will keep looking into this.

I found out what is happening:

https://projects.theforeman.org/issues/26645

Thank you, Ondrej.

Let me know if I can be of assistance.

i’ve got the same problem but the difference is that when i create new host, the switcher is still not visible (and has never been) :

Yeah, same here, but i would guess that it has the same cause - something is wrong with the rendering …

Good morning/evening/etc., Ondrej.

I’ve chased down through your issues report to the pull request, and applied the change (single token change to /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_ansible-2.3.3/app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb in my case.) Unfortunately… it seems to not have changed the visible behavior. I did stop Katello services prior to writing out the change, and started back up cleanly after.

Well, wait a sec…This is pulled from /var/log/foreman/production.log after application:

Started GET "/hosts/host.example.com/edit" for 172.24.29.167 at 2019-04-19 08:10:07 -0500
Processing by HostsController#edit as HTML
Parameters: {"id"=>"host.example.com"}
Current user set to admin (admin)
Rendering hosts/edit.html.erb within layouts/application
Deface: [WARNING][0m No :original defined for 'add_execution_interface_js', you should change its definition to include:
:original => '738d75b8975dc598101e60505810ef267e2c43ae' 
Deface: [WARNING][0m No :original defined for 'ansible_roles_tab', you should change its definition to include:
:original => '8c63c5282ee199068bfd65475e13066ee981089a' 
Deface: [WARNING][0m No :original defined for 'ansible_roles_tab_content', you should change its definition to include:
:original => '738d75b8975dc598101e60505810ef267e2c43ae' 
Rendered hosts/_progress.html.erb (0.8ms)
Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.11.0/app/views/overrides/activation_keys/_host_environment_select.html.erb (27.1ms)
Rendered hosts/puppet/_main_tab_fields.html.erb (11.0ms)
Rendered collection of puppetclasses/_selectedClasses.html.erb [0 times] (0.0ms)
Rendered collection of puppetclasses/_classes_in_groups.html.erb [0 times] (0.0ms)
Rendered puppetclasses/_classes.html.erb (1.0ms)
Rendered puppetclasses/_class_selection.html.erb (18.6ms)
Rendered hosts/puppet/_puppet_classes_tab.html.erb (20.0ms)
Deface: [WARNING][0m No :original defined for 'add_execution_interface', you should change its definition to include:
:original => 'dbe1da973bfb251a74b994e7ae11bc8d11502c97' 
Rendered nic/_base_form.html.erb (76.0ms)
Rendered nic/_virtual_form.html.erb (3.5ms)
Rendered nic/_provider_specific_form.html.erb (1.5ms)
Rendered nic/manageds/_managed.html.erb (97.3ms)
Rendered nic/_base_form.html.erb (71.3ms)
Rendered nic/_virtual_form.html.erb (1.5ms)
Rendered nic/_provider_specific_form.html.erb (0.2ms)
Rendered nic/manageds/_managed.html.erb (76.8ms)
Rendered hosts/_interfaces.html.erb (179.0ms)
Rendered common/os_selection/_architecture.html.erb (6.0ms)
Rendered /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_bootdisk-14.0.0/app/views/hosts/provision_method/bootdisk/_form.html.erb (0.9ms)
Deface: [WARNING][0m No :original defined for 'hosts_select_media_type', you should change its definition to include:
:original => '356145b9d744833e37767c56700139090bc696d7' 
Deface: [WARNING][0m No :original defined for 'hosts_select_synced_content', you should change its definition to include:
:original => '356145b9d744833e37767c56700139090bc696d7' 

I’ve taken the liberty of removing timestamps and greeking the hostname, as well as what appear to be greeked non-printable characters. This contains all of the errors and warnings (some of which I’m quite sure simply do not apply to this issue, such as the interface and OS warnings.)

As this is a complete sandbox environment (both of them, actually,) I have complete freedom for changes and testing.

Thanks for testing the patch, however it needs a change in Foreman for the issue to be fixed:

https://projects.theforeman.org/issues/26651

1 Like

Thanks again. I’ll wait for more news.

Hi,
I try to use the fix from the github pull request but I can not find the index.js. Where should this file? It would be great if I had a workaround until the patch is upstream.

CentOs7
foreman: 1.21.3
foreman_ansible: 2.3.3

I see that it was resolved and the pull request merged a few hours ago. Thank you for fielding the bug and resolving the issue, Ondrej!

I’m curious how these are released once they’re merged. Will it appear as an typical incremental package update within the Foreman 1.21 lifecycle, or will it be held for a later version? (I haven’t been tracking the Foreman community long, so please take this as an information seeking question and not evidence of impatience.)

The new release 3.0.1 was only planned for 1.22. I was unaware that this is reproducible with 1.21, we may need to do another 2.3.z release. Once that happens, you will see that as regular update in 1.21 repositories.

1 Like

Hi Marek,

as far as i can see, there is a new relase 2.3.4. Will this be released to .deb and .rpm too?
Thanks to all for fixing this bug.

Regards,
Bastian

Hello, @Ondrej_Prazak opened a request for rpm and I believe will open one for deb too. Ondra, let me know if you need any help with it.

Packaging PR for deb is now opened as well.