I have a module apt (my custom module, I am learning and want to explore more) for apt-get update
. I also have two user defined resource type apt::key
and apt::source
.
Let say I want to install a package example docker
for which we need to add an apt key and source. Hence I ideally want execution to happen in order
Now I want to ensure I am also having my code sitting under correct classes and following correct dependencies. My directory structure looks like
├── apt
│ └── manifests
│ ├── init.pp
│ ├── key.pp
│ ├── packages.pp
│ ├── source.pp
│ └── update.pp
└── docker
└── manifests
├── init.pp
├── install.pp
where should my definition of key and source for docker and how should I achieve the dependency? Should my dependency be inside these modules or in default manifest file under node definition?
EDIT: Adding little more context I am confused as I can achieve this by with two alternatives:
Hence I want to see how people achieve this and are there other alternatives which I haven't thought.
having docker::install have apt::source and apt::key for docker
I think this is the correct approach, as it contains/encapsulates all of the resources neatly into the module (docker
) that requires them.
Though the problem with this approach is I have to run apt update after each apt source change.
This is something the system should be doing - if the source changes, e.g. a URL change, you ought to be running apt-get update
to reload the package lists as they may be out of date. It seems unlikely to me that the source would change often.
If you have multiple apt sources across the catalog (i.e. from other modules) then the Puppet agent will still only refresh the Exec[apt_update]
once, after it's evaluated all of the apt source resources (notifying something puts an implicit before
relationship in too.)