theforeman / foreman_hooks

Run custom hook scripts on Foreman events
http://m0dlx.com/blog/Extending_Foreman_quickly_with_hook_scripts.html
GNU General Public License v3.0
56 stars 50 forks source link

Foreman Hooks missing data #34

Closed gzuki closed 8 years ago

gzuki commented 8 years ago

He we have a problem with foreman 1.11.x: http://projects.theforeman.org/issues/14812 Maybe you can help with this?

Thank you!

domcleal commented 8 years ago

Hi, since 1.11.0 most of informations gone in the foreman_hooks. Before we had:

{"host":{"ip":"10.15.254.5","environment_id":null,"environment_name":null,"last_report":null,"mac":null,"realm_id":null,"realm_name":null,"sp_mac":null,"sp_ip":null,"sp_name":null,"domain_id":2,"domain_name":"spibund.local","architecture_id":2,"architecture_name":"x86_64","operatingsystem_id":2,"operatingsystem_name":"RHEL 7.2","subnet_id":2,"subnet_name":"MGMT-Soft","sp_subnet_id":null,"ptable_id":122,"ptable_name":"RedHat-Default","medium_id":16,"medium_name":"RHEL-7","build":true,"comment":"","disk":"","installed_at":null,"model_id":null,"model_name":null,"hostgroup_id":18,"hostgroup_name":"TEST-MGMT-QS-Linux","owner_id":8,"owner_type":"User","enabled":true,"puppet_ca_proxy_id":null,"managed":true,"use_image":null,"image_file":"","uuid":null,"compute_resource_id":4,"compute_resource_name":"LYO","compute_profile_id":36,"compute_profile_name":"TEST-MGMT-QS-Linux","capabilities":["build","image"],"provision_method":"build","puppet_proxy_id":null,"certname":"linux01.domain.local","image_id":null,"image_name":null,"created_at":null,"updated_at":null,"last_compile":null,"global_status":0,"global_status_label":"OK","puppet_status":0,"build_status":1,"build_status_label":"Pending installation","name":"linux01.domain.local","id":null,"parameters":[],"interfaces":[{"id":null,"name":"linux01.domain.local","ip":"10.15.254.5","mac":null,"identifier":"","primary":true,"provision":true,"type":"interface"}],"puppetclasses":[],"config_groups":[],"all_parameters":[{"id":46,"name":"WINDOMAINFULL","value":"DOMAIN.LOCAL"},{"id":44,"name":"WINDOMAIN","value":"DOMAIN"},{"id":40,"name":"MAILRELAY","value":"mail.domain.local"},{"id":42,"name":"MAILDOMAIN","value":"domain.de"}],"all_puppetclasses":[]}}

now there is only:

{"host":{"id":null,"name":"linux01.domain.local","last_compile":null,"last_report":null,"updated_at":null,"created_at":null,"root_pass":"xyz","architecture_id":2,"operatingsystem_id":4,"environment_id":null,"ptable_id":124,"medium_id":18,"build":true,"comment":"bla","disk":"","installed_at":null,"model_id":null,"hostgroup_id":12,"owner_id":18,"owner_type":"User","enabled":true,"puppet_ca_proxy_id":null,"managed":true,"use_image":null,"image_file":"","uuid":null,"compute_resource_id":4,"puppet_proxy_id":null,"certname":"linux01.domain.local","image_id":null,"organization_id":null,"location_id":null,"otp":null,"realm_id":null,"compute_profile_id":34,"provision_method":"build","grub_pass":"","global_status":0,"lookup_value_matcher":"fqdn=linux01.domain.local"}}
gzuki commented 8 years ago

Hi, thank you for moving. Any idea about that issue?

mleklund commented 8 years ago

This one is also biting me. We use data such as subnet_name, and location_name to orchestrate some other things that are not directly controlled by foreman.

Though I guess that most of that could be had from the ids, but I didn't really want to connect to postgres, or the API to get that info.

sasskinn12 commented 8 years ago

Yes, we have exactly same problem, we are using host: parameters in hooks and now after upgrade to 1.11.x they are not forwarded to hooks anymore :( Can somebody fix that?

depatl commented 8 years ago

Joining this request. we are using host_parameters_attributes to orchestrate BMC configuration prior the host creation.

lzap commented 8 years ago

It looks like MAC address is not available in after_build hook as well, which prevents the UEFI TFTP workaround in Satellite 6.2. Could ae46f241cbea6f4f3ecea56c3b072c3aeef06973 cause this (comparison of string vs constant)?

lzap commented 8 years ago

I am getting

2016-05-10T13:07:19 [sql] [D] Running hook: /home/lzap/work/foreman/config/hooks/host/managed/create/00_test.sh create fake10c469.local.lan
2016-05-10T13:07:19 [sql] [W] Unable to render fake10c469.local.lan (Host::Managed) using RABL: undefined method `facets_with_definitions' for nil:NilClass
2016-05-10T13:07:19 [sql] [D] /home/lzap/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rabl-0.12.0/lib/rabl/engine.rb:419:in `instance_eval'
 | /home/lzap/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rabl-0.12.0/lib/rabl/engine.rb:419:in `instance_eval'
 | /home/lzap/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rabl-0.12.0/lib/rabl/engine.rb:419:in `eval_source'
 | /home/lzap/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rabl-0.12.0/lib/rabl/engine.rb:35:in `apply'
 | /home/lzap/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rabl-0.12.0/lib/rabl/renderer.rb:54:in `render'
 | /home/lzap/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rabl-0.12.0/lib/rabl.rb:77:in `render'
 | /home/lzap/work/foreman_hooks/lib/foreman_hooks/util.rb:21:in `render_hook_json'
 | /home/lzap/work/foreman_hooks/lib/foreman_hooks/util.rb:32:in `block in exec_hook'
 | /home/lzap/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.10.5/lib/bundler.rb:245:in `block in with_clean_env'
 | /home/lzap/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.10.5/lib/bundler.rb:232:in `with_original_env'
 | /home/lzap/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.10.5/lib/bundler.rb:238:in `with_clean_env'
 | /home/lzap/work/foreman_hooks/lib/foreman_hooks/util.rb:32:in `exec_hook'
 | /home/lzap/work/foreman_hooks/lib/foreman_hooks/orchestration_hook.rb:56:in `hook_execute_set'
 | /home/lzap/work/foreman/app/models/concerns/orchestration.rb:162:in `execute'
 | /home/lzap/work/foreman/app/models/concerns/orchestration.rb:107:in `block in process'
 | /home/lzap/work/foreman/app/models/concerns/orchestration.rb:99:in `each'
 | /home/lzap/work/foreman/app/models/concerns/orchestration.rb:99:in `process'
 | /home/lzap/work/foreman/app/models/concerns/orchestration.rb:35:in `on_save'

Investigating.

lzap commented 8 years ago

Found it, RABL issue, reported here: http://projects.theforeman.org/issues/14981

lzap commented 8 years ago

The issue was NOT fully fixed, it was only fixed when creating hosts via API. When using UI another error message appears:

Unable to render fake-fdafsd.vlan98.coe.muc.redhat.com (Host::Managed) using RABL: Cannot find rabl template 'katello/api/v2/content_facet/base_with_root' within registered (["app/views", "/usr/share/foreman/app/views"]) view paths!
domcleal commented 8 years ago

That looks like a different issue and message, closing this as it's been fixed in Foreman core and will be released shortly.

lzap commented 8 years ago

For the record the fix for the above is here: https://github.com/theforeman/foreman_hooks/pull/36