Puppet comes with the “modules” subcommand. This command let’s you do a number of things including installing modules from puppetforge, which is the official library where the wider puppet community share their modules with others.
AnnouncementI have released my new course on Udemy, Kubernetes By Example. Sign up now to get free lifetime access!
The modules subcommand can list all installed modules:
[root@puppetmaster puppet]# puppet module list /et/puppet/modules ├── adrien-alternatives (v0.3.0) ├── adrien-boolean (v1.0.1) ├── garethr-docker (v3.3.1) ├── garethr-erlang (v0.3.0) ├── iaac-eclipse_platform (v0.1.0) ....etc.
If any modules are installed but they are dependent on other modules that haven’t been installed yet, then this command will output a warning message to indicate this.
Now let’s say we want to install the apache module, then we run:
[root@puppetmaster /]# puppet module install puppetlabs-apache Notice: Preparing to install into /git_source/puppet/environments/dev_virtualbox_v2/modules ... Notice: Downloading from https://forge.puppetlabs.com ... Notice: Installing -- do not interrupt ... /etc/puppet/modules └─┬ puppetlabs-apache (v1.2.0) └── puppetlabs-concat (v1.1.2) [root@puppetmaster /]#
Notice that the concat module has also been installed. That’s because concat is a dependency of the apache module. It hasn’t downlaoded the puppetlabs/stdlib module because that is already installed on our puppetmaster.
Hence in that respect, the puppet module install command manages dependancies just like yum does with rpm packages.
In the background, what really ends up happening is that puppet creates a folder for each module in the modules folder. This folder is just the name of the module, i.e. without the author prefix:
[root@puppetmaster modules]# ls -l | grep -E 'apache|concat' drwxr-xr-x 8 root root 4096 Nov 12 01:38 apache drwxr-xr-x 7 root root 4096 Oct 28 19:13 concat
It then downlaods the module files in tar ball form (the tarball link is also available on the module puppetforge page but in very small font) and extracts it into the folder.
When we then do a “puppet module list”, puppet scans each modules folder for a “metadata.json” files, and extract the module’s fqdn (authorName-moduleName) along with the version. This file also lists the dependendant modules, which is how “puppet module install” new which dependancies to automatically install.