└── manifests |
└── init.pp7 directories, 5 files |
vagrant@ubuntu-focal:/vagrant/environment/testing$ cat hiera.yaml |
version: 5 |
hierarchy: |
- name: "Configure each module seperately" |
path: "%{module_name}.yaml" |
|
vagrant@ubuntu-focal:/vagrant/environment/testing$ cat modules/{a,b}/manifests/init.pp |
class a ($key) { |
notice($key) |
notice(lookup("b::key",undef,undef,"lookup for b::key failed")) |
} |
class b ($key) { |
notice($key) |
notice(lookup('b::key',undef,undef,"lookup for b::key failed")) |
} |
|
This shows the issue, automatic parameter lookup works fine, lookup of data for another module does not.
vagrant@ubuntu-focal:/vagrant/environment/testing$ puppet apply --codedir=. -e 'include a' |
Notice: Scope(Class[A]): keyA |
Notice: Scope(Class[A]): lookup for b::key failed |
Notice: Compiled catalog for ubuntu-focal.workspace.rug.nl in environment production in 0.05 seconds |
Notice: Applied catalog in 0.01 seconds
|
this shows that module b works correctly:
vagrant@ubuntu-focal:/vagrant/environment/testing$ puppet apply --codedir=. -e 'include b' |
Notice: Scope(Class[B]): keyB |
Notice: Scope(Class[B]): keyB |
Notice: Compiled catalog for ubuntu-focal.workspace.rug.nl in environment production in 0.04 seconds |
Notice: Applied catalog in 0.01 seconds
|
I added a default value for{{ lookup()}} to prevent the commands from failing. On close examination of the documentation it seems that the lookup() function works as described, that is not the issue. It is more that this usage should also work. Currently I can work around the problem by adding a per-module hiera.yaml file with a datadir pointing back to the environment datadir. But that seems abit hackish. |