Project

General

Profile

Bug #23104

Host parameters not available in foreman_hooks

Added by Anthony Chevalet over 2 years ago. Updated about 2 years ago.

Status:
Need more information
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

The json file which describes the host during 'create' does not contain the parameters set at host level but only the inherited parameters (hostgroup, subnet...).
Thus we can't use a host parameter as a conditional in hook host/create.
It probably relates to #20062.


Related issues

Related to Foreman - Bug #20062: Host parameter not rendered in user_data template New

History

#1 Updated by Anthony Chevalet over 2 years ago

  • Related to Bug #20062: Host parameter not rendered in user_data template added

#2 Updated by Anthony Chevalet about 2 years ago

  • Found in Releases 1.19.0-RC3 added
  • Found in Releases deleted (1.15.6)

#3 Updated by Anthony Chevalet about 2 years ago

  • Subject changed from Host parameters not available in foreman_hooks host create to Host parameters not available in foreman_hooks

Same behaviour for hook host/managed/destroy.

The API shows the parameters in .parameters and .all_parameters keys:

$ curl -kns https://katello-01.net/api/v2/hosts/host-03.net | jq '{parameters, all_parameters}'
{
  "parameters": [
    {
      "priority": 70,
      "created_at": "2018-08-30 13:53:29 UTC",
      "updated_at": "2018-08-30 13:53:29 UTC",
      "id": 460,
      "name": "manage-volumes",
      "value": "true" 
    }
  ],
  "all_parameters": [
    {
      "priority": 70,
      "created_at": "2018-08-30 13:53:29 UTC",
      "updated_at": "2018-08-30 13:53:29 UTC",
      "id": 460,
      "name": "manage-volumes",
      "value": "true" 
    },
    {
      "priority": 60,
      "created_at": "2018-08-22 12:32:01 UTC",
      "updated_at": "2018-08-22 23:33:30 UTC",
      "id": 156,
      "name": "kt_activation_keys",
      "value": "upstream" 
    },
...

But the json file used in hooks does not:

$ jq '.host|{parameters, all_parameters}' ~foreman/tmp/foreman_hooks-destroy.zRfOLSZXzL
{
  "parameters": [],
  "all_parameters": [
    {
      "priority": 60,
      "created_at": "2018-08-22 12:32:01 UTC",
      "updated_at": "2018-08-22 23:33:30 UTC",
      "id": 156,
      "name": "kt_activation_keys",
      "value": "upstream" 
    },
...

#4 Updated by Lukas Zapletal about 2 years ago

  • Status changed from New to Need more information

I am afraid that post queue won't show any data after commit. Well that was just a guess, go and try it I created a patch for you:

https://github.com/theforeman/foreman_hooks/pull/58

#5 Updated by Anthony Chevalet about 2 years ago

Same behaviour with postdestroy.
There is a related issue at https://github.com/theforeman/foreman_hooks/issues/48
With this workaround it works, but only for create:

sed -i 's:host.host_parameters.authorized:host.host_parameters:' \
  /usr/share/foreman/app/views/api/v2/hosts/main.json.rabl

Also available in: Atom PDF