Ask Your Question

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

asked 2015-08-26 14:29:53 -0500

Red Cricket gravatar image

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

$swift_cert_content = '

... 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 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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-08-26 15:10:27 -0500

updated 2015-08-26 15:10:45 -0500

puppet apply will take no notice of your site.pp file, therefore the top-scope variable you're using in your create_cert_files class will not have been defined.

From this page

Puppet apply does not use the manifest from an environment; it always uses the manifest given on the CLI.
edit flag offensive delete link more



Thanks Chris your answer lead me to a solution. I need to do this: `cat /etc/puppetlabs/puppet/manifests/site.pp create_cert_files.pp > runthis.pp ; puppet apply runthis.pp`

Red Cricket gravatar imageRed Cricket ( 2015-08-26 15:50:34 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-08-26 14:29:53 -0500

Seen: 273 times

Last updated: Aug 26 '15