Project

General

Profile

Actions

Bug #19465

open

User data template rendering does not render host parameters

Added by Tyler Gregory almost 8 years ago. Updated 7 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Templates
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

When a host parameter is specified at creation time (ie not inherited from a host group or something similar), either in the UI or in a POST request via the API, the parameter is not bound to @host.params before the template is rendered and sent to the compute resource.


Related issues 1 (1 open0 closed)

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

Updated by Marek Hulán over 7 years ago

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

Updated by Marek Hulán over 7 years ago

  • Status changed from New to Need more information

What version of Foreman do you experience this with? Do you use organizations or locations?

Actions #3

Updated by Tyler Gregory over 7 years ago

It was experienced on version 1.14.3, and yes we do use organizations and locations

Actions #4

Updated by Marek Hulán about 7 years ago

  • Status changed from Need more information to New
Actions #5

Updated by Ondřej Pražák over 6 years ago

  • Bugzilla link set to 1568697
Actions #6

Updated by Oleh Fedorenko 7 days ago

This is still valid: https://community.theforeman.org/t/shellhook-and-host-parameter/41994.

Few notes:
- During host creation, such host parameters are not being saved before they are used in provisioning templates during orchestration.
- During provision templates render, such parameters are being called and then cached in https://github.com/theforeman/foreman/blob/3.14-stable/app/models/concerns/host_params.rb#L65.
- The cache is not global and stays until a host object is discarded. The issue is rather in https://github.com/theforeman/foreman/blob/3.14-stable/app/models/concerns/host_params.rb#L24, more specifically in how we check for permissions.
- In https://github.com/theforeman/foreman/blob/3.14-stable/app/models/concerns/authorizable.rb#L50-L58 we're referring to the model itself (e.g. HostParameter.all) and thus fully ignoring currently unsaved host parameters.
- Due to the above, https://github.com/theforeman/foreman/blob/3.14-stable/app/models/concerns/host_params.rb#L24 will always return an empty array for new parameters during host creation, then caching it for current host object, which will lead to such errors until the host object is then reloaded with already saved host parameters object from DB.

Actions

Also available in: Atom PDF