I want to create a new file on a specific Puppet agent and store the output of a Linux command to the file. Is there an easy way to do this with the content
attribute? The command I want to run is
file { '/home/akrall/out_string':
ensure => 'file',
owner => 'andreas',
group => 'andreas',
mode => '400'
content => '<the output of the command would go here>'
}
The command itself that I want to run is openssl rand -hex 32
, and I want to ensure that it's unique for every agent, so that's why I opted not to store it as a Puppet variable and send the same variable to multiple agents due to the fact that it would be the same string for every agent. Can anyone tell me how to do this? I tried content => '"$(openssl rand -hex 32)"'
and that didn't work for me, and I'm not sure what else I should try.
Edit: If there's no easy way to do it with content
, I can just use exec
with the command to write the output to the file, but I was hoping there was something I could do with file
so I could keep it all in the same resource.