Ask Your Question
0

Puppet : set a variable only at runtime

asked 2017-02-16 07:15:38 -0600

craymore gravatar image

Hi all,

I'm currently facing an interesting challenge :

  • I use puppet to setup a middleware
  • in order to be able to use this middleware once it's installed, I need to query it in order to get a ( unique ) key
  • once I have this key, I can use it in order to configure other products depending on this middleware

The problem :

  • I use templates in order to deliver the configuration for the products depending on the middleware, but these use static hiera configuration files in order to resolve the variables

How can I inject ( in a template ), a value ( this unique key ) which is unknown until a certain point in the puppet deployment ?

Thanks beforehand for any answer.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-02-16 08:25:50 -0600

DarylW gravatar image

Problem is that with a template, they are complied before any resources are applied to the server.

Two ideas come to mind.

  1. Two phase puppet run - If you have a fact that can get the information, you can use it in the second run.

  2. If you don't care about maintaining the file with the template, only creating it, you can use the replace parameter and set it to false... that way when the file initial does not exist, puppet would ensure it's contents from the template. You could then use augeas / file_line / exec to update the value for the unique key in the file, and puppet just won't manage it.

edit flag offensive delete link more

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

Stats

Asked: 2017-02-16 07:15:38 -0600

Seen: 32 times

Last updated: Feb 16