I don't know if it is even possible. I have a manifest like this:
$some_external_value = 'pew_pew'
$dict = {
ensure => $ensure,
configuration => {
"random_name-${some_external_value}" => {
command => 'python script.py config/random_name-${some_external_value}.cfg',
},
"some_other_name-${some_external_value}" => {
command => 'python script.py config/some_other_name-${some_external_value}.cfg',
},
"without-external" => {
command => "python script.py config/without-external.cfg",
user => 'cluster',
},
}
}
notice ($dict["configuration"]["some_other_name-${some_external_value}"]["command"])
I get
notice: Scope(Class[main]): python script.py config/some_other_name-pew_pew.cfg
Is there some trick to write key name just once and after that just refer it?
"some_other_name-${some_external_value}" => {
command => 'python script.py config/${wild_magic_variable_pasting_key_here}.cfg',
},
You can likely get there either with a custom parser function .
$orig_dict = {
...
configuration => {
"random_name-${some_external_value}" => {
command => 'python script.py config/__KEY__.cfg',
},
...
}
$dict = keysubst($orig_dict)
...where the ruby function does the work of replacing the __KEY__
token with the respective key value recursively.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.