-2

I'm trying to resolve a YAML value in a module

file { '/boot/config.txt' :
ensure      => present,
mode        => '0755',
content => $::hostname?{
     'serverName1.domain' => template('template1'),
     default => template('template2'),
     }
}

above with hardcoded names works nicely, however I'm trying to something like this:

file { '/boot/config.txt' :
ensure      => present,
mode        => '0755',
content => $::hostname?{
     <%= scope.call_function('hiera',['server_name_in_hiera']) %> => template('template1'),
     default => template('template2'),
     }
}

I'm sure its doable and I'm just doing something stupid.

Thanks

1

Figured it:

file { '/boot/config.txt' :
ensure      => present,
mode        => '0755',
content => $::hostname?{
     hiera('server_name_in_hiera') => template('template1'),
     default => template('template2'),
     }
}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.