How to model a sequence of steps in Puppet DSL?

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:

stop service

call uninstall script to deregister service

delete files

download new files

unzip them

make some configurations

call script to register service

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.

2 Answers

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):

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

Comments

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.

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.