Ask Your Question

How to model a sequence of steps in Puppet DSL?

asked 2015-06-10 10:04:22 -0600

sinned gravatar image

I'm using puppet to manage a windows server, where I have a self-written piece of software, registered as a service.

I want to write a module which installs it and ensures that always the current version is installed.

What I have are a few resources chained together to uninstall and reinstall the software:

  1. stop service
  2. call uninstall script to deregister service
  3. delete files
  4. download new files
  5. unzip them
  6. make some configurations
  7. call script to register service
  8. ensure the service is started and has the current version

Since the last one is an "ensure", I suspect it only does something if the state of the system is not as desired. The previous steps are "required" sequentially, so I want them only to be executed when the last steps ensure fails.

The implementation is not yet finished, but I suspect puppet doesn't work like this. For example, in step six I generate a configuration file as a file ressource which also has an ensure. Also, the very first step has an ensure to stop the service.

How to model a sequence of steps in Puppet DSL? Follow up question: If puppet dsl is not the place to do this, how to do this? Mind I am managing windows here, I don't want to use a 3rd party package provider. I also don't want to repackage my software to msi.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-06-11 07:27:21 -0600

oldNoakes gravatar image

Just going to throw in my 2 cents on this - while you may not want to repackage your software within an msi, it seems like the best fit for what you are attempting here.

Of the 8 steps you have listed, the only steps I would consider adding to my puppet setup are steps 6 and 8 as they are the only ones that specify the end state that you want your machine to be in (maybe 7 as well) - e.g. I want version 1.3.64 installed and its config should look like this (and it should be registered). The remaining steps really are about how your app installs itself. If you consider a scenario where you have successfully mangled the above steps into puppet but you have lost your puppet installation (for whatever reason), you are now left in a situation where you cannot install your app to the desired version - is that where you want to go with this?

That said, I don't know your situation and there might be a very good reason for wanting to do this via puppet that I am not aware of in which case, I would advocate that you simply use an exec for this - something along the lines of (pseudocode):

version = args[0]
return SUCCESS if is_installed(version)

if service_exists
  deregister service


Not done in pure puppet DSL but, as I said above, the DSL is supposed to represent the desired state of your system - it generally relies on other tooling for getting to that desired state (e.g. packaged installations).

edit flag offensive delete link more

answered 2015-06-10 11:06:44 -0600

run stages?

link text

edit flag offensive delete link more


I see how ressource execution can be ordered this way, but require seems sufficient in my case. What I still don't know is when this process is triggered. I want to run it when the last ressource (e.g. the version number) is wrong. Only then do the reinstall. NOT on every puppet run.

sinned gravatar imagesinned ( 2015-06-10 14:09:41 -0600 )edit

By the way, this is a simple software installation, the documentation on run stages states that "Mass dependencies like package repositories are effectively the only valid use case.". So I guess it will just introduce surpluss complexity here.

sinned gravatar imagesinned ( 2015-06-10 14:15:10 -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


Asked: 2015-06-10 10:04:22 -0600

Seen: 227 times

Last updated: Jun 10 '15