Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hiera.yaml without datadir explicitly set causes an error upon selecting a node #204

Closed
tuxmea opened this issue Oct 14, 2023 · 1 comment · Fixed by #212
Closed

hiera.yaml without datadir explicitly set causes an error upon selecting a node #204

tuxmea opened this issue Oct 14, 2023 · 1 comment · Fixed by #212
Labels
bug Something isn't working

Comments

@tuxmea
Copy link
Member

tuxmea commented Oct 14, 2023

Fresh installation of container v1.2.0

  • Create admin - OK
  • Crate User - OK
  • Login as User - OK
  • Select environment - OK
  • Select node - ERROR
Internal Server Error
If you are the administrator of this server, please check the hdm log file for the full error message.

In case the issue persists, please consider opening an issue here: https://github.com/betadots/hdm/issues/new

Reason: hiera.yaml has no default datadir set:

---
version: 5
defaults:
  # The default value for "datadir" is "data" under the same directory as the hiera.yaml
  # file (this file)
  # When specifying a datadir, make sure the directory exists.
  # See https://puppet.com/docs/puppet/latest/environments_about.html for further details on environments.
  # datadir: data
  # data_hash: yaml_data
hierarchy:
  - name: "Per-node data (yaml version)"
    path: "nodes/%{::trusted.certname}.yaml"
  - name: "Other YAML hierarchy levels"
    paths:
      - "common.yaml"

Docker logs:

I, [2023-10-13T13:25:07.432133 #24]  INFO -- : [1e457829-75f1-41e6-8242-2cdc207bc17e] Started GET "/environments/production/nodes/puppet.enterprise.betadots.training/keys" for 10.200.20.1 at 2023-10-13 13:25:07 +0000
I, [2023-10-13T13:25:07.433086 #24]  INFO -- : [1e457829-75f1-41e6-8242-2cdc207bc17e] Processing by KeysController#index as HTML
I, [2023-10-13T13:25:07.433178 #24]  INFO -- : [1e457829-75f1-41e6-8242-2cdc207bc17e]   Parameters: {"environment_id"=>"production", "node_id"=>"puppet.enterprise.betadots.training"}
I, [2023-10-13T13:25:07.525811 #24]  INFO -- : [1e457829-75f1-41e6-8242-2cdc207bc17e] Completed 500 Internal Server Error in 93ms (ActiveRecord: 0.5ms | Allocations: 9635)
F, [2023-10-13T13:25:07.526421 #24] FATAL -- : [1e457829-75f1-41e6-8242-2cdc207bc17e]   
[1e457829-75f1-41e6-8242-2cdc207bc17e] NoMethodError (undefined method `merge' for nil:NilClass):
[1e457829-75f1-41e6-8242-2cdc207bc17e]   
[1e457829-75f1-41e6-8242-2cdc207bc17e] app/models/hiera_data/config.rb:33:in `block in initialize_hierarchies'
[1e457829-75f1-41e6-8242-2cdc207bc17e] app/models/hiera_data/config.rb:31:in `map'
[1e457829-75f1-41e6-8242-2cdc207bc17e] app/models/hiera_data/config.rb:31:in `initialize_hierarchies'
[1e457829-75f1-41e6-8242-2cdc207bc17e] app/models/hiera_data/config.rb:8:in `initialize'
[1e457829-75f1-41e6-8242-2cdc207bc17e] app/models/hiera_data.rb:141:in `new'
[1e457829-75f1-41e6-8242-2cdc207bc17e] app/models/hiera_data.rb:141:in `config'
[1e457829-75f1-41e6-8242-2cdc207bc17e] app/models/hiera_data.rb:28:in `all_keys'
[1e457829-75f1-41e6-8242-2cdc207bc17e] app/models/key.rb:8:in `all_for'
[1e457829-75f1-41e6-8242-2cdc207bc17e] app/controllers/keys_controller.rb:10:in `index'
@tuxmea tuxmea added the bug Something isn't working label Oct 14, 2023
@tuxmea tuxmea changed the title Selecting nodes causes error hiera.yaml without datadir explicitly set causes an error upon selecting a node Oct 14, 2023
oneiros added a commit that referenced this issue Nov 2, 2023
Merging hiera's defaults did not work when `defaults` was
given in `hiera.yaml`, but empty (== `nil`).
@oneiros
Copy link
Collaborator

oneiros commented Nov 2, 2023

This was a tricky one: The problem was not that datadir was missing. We get all the defaults directly from puppet/hiera and datadir is one of them.

The problem was, that this hiera.yaml includes the key defaults, but leaves it completely empty. We take the defaults from hiera and merge them with the defaults from hiera.yaml, so those take precedence. But in this case, the yaml parser will parse this as {defaults: nil} and, as it turns out, this overwrites the hiera defaults completely when merging.

I prepared a fix in #212

tuxmea pushed a commit that referenced this issue Nov 2, 2023
Merging hiera's defaults did not work when `defaults` was
given in `hiera.yaml`, but empty (== `nil`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants