Puppet: maintaining apt sources.list

aptpuppet

I'm using puppet to maintain a growing pile of debian machines. These will be maintained from their initialization onwards. This means that one step will be setting the apt 'sources.list' file and then updating it.

There are other modules that rely on this list being up to date and will fail if apt-get update hasn't been called. What I'm wondering is should I introduce some sort of ordering process (using stages or similar) to ensure that the package list is updated before attempting to install apps or just assume that it will likely fail on the first run but work on subsequent runs once the list is updated?

The ethos of puppet seems to be declaring a 'final state' rather than a process. This leads me to believe that letting the errors occur is probably the way to go.

Best Answer

You can use an exec resource with refreshonly => true that gets notified when the sources.list file changes. And have the class containing both the file management resource and the exec resource be a require from the package resources that need them.

The way I'd recommend approaching this in a simpler way would be to manage the sources through the apt::source resource type in the apt module from Puppet Labs, which handles the update as well.