Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Writing variables defined in site.pp to file on puppet master

On my puppet master I have a site.pp file that defines the content of some certificates like so ...

$swift_cert_content = '
-----BEGIN CERTIFICATE-----
blhablhadfblhablah...
-----END RSA PRIVATE KEY-----
'

... and I want to write the value of $swift_cert_content to the file /tmp/swift_cert on my puppet master. I have tried this ...

# cat create_cert_files.pp 
class create_cert_files (
  $swift_cert_content = $::swift_cert_content,
) {
  file { '/tmp/swift_cert':
    ensure => "file",
    content => $swift_cert_content,
  } 
}

class { 'create_cert_files': }

... and I execute this like so ...

# puppet apply create_cert_files.pp 
Notice: Compiled catalog for osc-ppt-001.example.com in environment production in 0.16 seconds
Notice: /Stage[main]/Create_cert_files/File[/tmp/swift_cert]/ensure: created
Notice: Finished catalog run in 0.31 seconds

... but the file is empty:

# ls -l /tmp/swift_cert 
-rw-r--r-- 1 root root 0 Aug 26 14:55 /tmp/swift_cert

What am I doing wrong?