'Set variable to be contents of file
Running Puppet 3.5
I've got a case definition that checks for matching FQDNs, then sets a variable to be a static file depending on the FQDN. There is a total of 4 FQDN match cases, but that could grow, so I am trying to make this scalable without duplicating 10 lines of code for each case.
As an example, my source file is in modules/auth/files/bi-k5login on the puppetmaster. It's a list of users, 1 per line. The variable will then be used as an input to write the file in another function.
I've tried:
$princs = file('auth/files/bi-k5login')
$princs = file('auth/bi-k5login')
$princs = file('puppet:///modules/auth/bi-k5login')
And each time, I get a "Files must be fully qualified" error.
Either my syntax is wrong, or I cannot use the file() function the way I am intending. Since this is super old Puppet 3.5, documentation is hard to come by.
Prior to my current issue, I had this working by referencing the file a different way, but it added a lot more lines of code.
file { '/root/.k5login' :
ensure => 'present',
mode => '0640',
owner => 'root',
group => 'root',
source => 'puppet:///modules/auth/bi-k5login',
seltype => 'krb5_home_t',
selrole => 'object_r',
seluser => 'system_u',
}
THIS works just fine, but repeat that for each possible case (but using a different k5login file) and the file grows in size awfully quick and I am trying to avoid that.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
