Project

General

Profile

Actions

Bug #23104

open

Host parameters not available in foreman_hooks

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

Status:
Need more information
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
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 1 (1 open0 closed)

Related to Foreman - Bug #20062: Host parameter not rendered in user_data template NewActions
Actions #1

Updated by Anthony Chevalet over 6 years ago

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

Updated by Anthony Chevalet about 6 years ago

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

Updated by Anthony Chevalet about 6 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" 
    },
...

Actions #4

Updated by Lukas Zapletal about 6 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

Actions #5

Updated by Anthony Chevalet about 6 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
Actions

Also available in: Atom PDF