Ask Your Question
0

create a file if puppet module installs

asked 2017-08-18 11:50:06 -0600

monalsharma gravatar image

So I've got a huge puppet module that does all kinds of things:

setting up lvms creating new mount points configuring multiple files etc..

I just want to touch a file if the module is installed successfully. I'm not sure how to check the module install status and then touch a file. And then, if the file exists don't run the module again.

If you've done something similar, please help me out.

Thanks.

edit retag flag offensive close merge delete

Comments

I'm not sure what you mean by “install status of a module”, but you can create a `file` resource and make it dependent an all other resources defining that state. https://docs.puppet.com/puppet/latest/lang_relationships.html#behavior

Kai Burghardt gravatar imageKai Burghardt ( 2017-08-19 07:14:42 -0600 )edit

Well, I meant that once all the resources have applied successfully, create a file. So I can do a check for a file and make sure the module doesn't apply again if it exists. Thanks.

monalsharma gravatar imagemonalsharma ( 2017-08-21 08:56:43 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2017-08-19 11:38:43 -0600

bess gravatar image

What you're asking for can be done but totally goes against Puppets design pattern of idempotencany.

https://puppet.com/blog/idempotence-n...

Your Puppet code should adhere to idemotence and if not, make it so. :)

edit flag offensive delete link more

Comments

Understand that very well myself :) However, the problem is that this is not the "ideal" use case for Puppet, but for lack of options we need a stop gap kind of arrangement I just need to find out a way to check if all the resources in the module applied successfully -if yes- create a file Thanks

monalsharma gravatar imagemonalsharma ( 2017-08-21 09:00:24 -0600 )edit

Then write a (shell) script then, which does exactly what you want. To achieve such as behavior as you want is out of Puppet's scope.

Kai Burghardt gravatar imageKai Burghardt ( 2017-08-21 09:22:04 -0600 )edit

I don't know the structure of your Puppet code but you could use the idea of a "Profile" . In the profile, wrap the include $module_name around a conditional. So check to see if the file exists, if not, include the necessary code to create it.

bess gravatar imagebess ( 2017-08-21 12:47:23 -0600 )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

Stats

Asked: 2017-08-18 11:50:06 -0600

Seen: 131 times

Last updated: Aug 19