-
Notifications
You must be signed in to change notification settings - Fork 4
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
Allow doing lookups #283
Allow doing lookups #283
Conversation
Note on encryption: encryption only works on strings. |
Thanks for that, this was helpful. Also, I realized we only support top-level encrypted values anyway, so there is no need for something more complicated (for now). Still, I have to admit it has been quite a ride. I had to move a lot stuff around, but I believe it should do the trick now. Please play around with this and see if it works as expected. Also, please have a look at the test cases in |
87a4835
to
5c70043
Compare
Working perfectly and as expected. Order of the result is correct. A. Issue on Hash deep merge:
# data/nodes/foreman.betadots.training.yaml
hash:
'key1':
'key1sub1': 'key1sub1value'
'key1sub2':
'key1sub1sub1': 'key1sub1sub1value'
'key2':
'key2sub1': 'key2sub1value'
# data/common.yaml
---
lookup_options:
'hash':
merge: 'deep'
hash: 'data'
$hash = lookup('hash')
$hash.each |$key, $value| {
notify { $key:
message => "Key: ${key} - Value: ${value}",
}
}
B. Issue on data presentation:
|
Two things were going on here. I misinterpreted the requirements and documentation and actually threw an error when a I now fixed both: If an error is thrown it is being displayed and having scalar values in a deep merge no longer throws an error. There are two scenarios that still throw an error and I am a bit uncertain now if this is correct:
|
This is the result from a real puppet agent run:
Data: # common.yaml
---
lookup_options:
'array_unique':
merge: 'unique'
array_unique: 'string' # app/demo.yaml
---
array_unique:
- 'foo'
- 'bar' # nodes/foreman.betadots.training.yaml
---
array_unique:
'key': 'value' Puppet manifest: $array_unique = lookup('array_unique')
notify { 'arrayunique':
message => $array_unique,
} Result from Puppet agent:
Note: if we revert node data with common data we retreive an error from puppet: # node data:
array_unique: 'string'
# common data:
array_unique:
'key': 'value' Puppet result:
Common Data: # common.yaml
---
lookup_options:
'hash_merge':
merge: 'deep'
hash_merge:
'common':
'subkey1': 'subvalue1' App data: # app/demo.yaml
---
hash_merge:
'app':
subkey_app: 'subvalue_app' Node data: nodes/foreman.betadots.training.yaml
---
hash_merge: 'foobar' Puppet Manifest: $hash_merge = lookup('hash_merge')
notify { 'hashmerge':
message => $hash_merge,
} Puppet result:
THis does not follow the documentation. |
My opinion: When
When
I am interested how @bastelfreak and @rwaffen see this. |
First of all, I did not mean to confuse anyone. I think both our My specific concern was with what "the lookup fails" in the puppet docs means exactly. Also, my second point refered to the As for the two examples above: I have a hard time parsing the puppet output, but if what follows after "current_value 'absent', should be" is the result of the lookup I believe both examples to follow the documented behavior. As for my opinion of how HDM should be have, I will comment in the discussion. |
As promised I tried to remove the dangling three dots from the output. The good news is that I caught and fixed a bug related to unique merges of scalar values. The bad news is, I could not reproduce the "three dots" problem. They are indeed YAML syntax and yes, I use |
Example with 3 dots: hiera.yaml
Node YAML
hdm.yml
Lookup result for
|
@tuxmea could you file an issue at https://github.com/puppetlabs/puppet-docs/issues detailing the docs problem so someone can investigate it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Still no luck. @tuxmea how does |
My common.yaml file:
|
I am stumped. I cannot reproduce this even with the exact same files. The only idea I have is that we are using different versions of FWIW, the quick fix here would be really simple, but I would really like to understand where this difference in behavior comes from. I believe we observed at least one other difference (display of strings IIRC) and there might be more. Without knowing what causes this, it is hard to anticipate what else could go wrong and which way to fix this properly. On the other hand, I have already invested a lot of time into this problem, which is "only" a cosmetic issue. So I would be fine with either a) we merge this now or |
I've the same idea. At Vox Pupuli we had similar problems with json and yaml parsing where the same ruby code provided different results on different machines. The root cause was that sometimes psych was used. I think there was a workaround to prepend |
Ruby used to bundle another YAML parser, |
@oneiros I prefer to merge this one. |
This was flagged on CI but did not come up locally.
I have been working on #264 for a long time now, but finally have something to show:
This is probably still rough around the edges but works well for the cases I could come up with.
Feel free to play around with this, but please do not merge yet.
While I felt like I was almost finished, I realized an important piece of the puzzle is still missing: This does not currently work with encryption☹️
I am not sure how to implement this and will have to think about this some more.