Puppetfile with 'puppet apply'?

34 views
Skip to first unread message

Joaquin Menchaca

unread,
May 2, 2018, 3:55:12 AM5/2/18
to Puppet Users
Is it possible to use Puppetfile with 'puppet apply'?  I have been having difficulty finding this.  I wanted to use the Puppetfile to download and vendor modules in the modules directory.

From my research so far, it looks like r10k with open source puppet server, and code manager with PE, but for 'puppet apply', I couldn't find anything.


Joaquin Menchaca

unread,
May 2, 2018, 4:13:12 AM5/2/18
to Puppet Users
I got the lucky google search and found this gist: https://gist.github.com/brasey/030b318a37b07acd21af

I was able to get off the ground this below, but I am wondering, how do dependencies of dependencies get resolved?  Is this a manual thing?  r10k doesn't do a Puppetfile.lock?

sudo su -

curl -sSL https://get.rvm.io | bash

source /etc/profile.d/rvm.sh

rvm install 2.4.4

gem install r10k

r10k puppetfile install

puppet apply manifests/site.pp --modulepath=./site:./modules

puppet module list --tree --modulepath=./site:./modules

/path/to/modules

└─┬ puppetlabs-apt (v4.5.1)

  └── UNMET DEPENDENCY puppetlabs-stdlib (>= 4.16.0 < 5.0.0)


Joaquin Menchaca

unread,
May 2, 2018, 5:34:55 AM5/2/18
to Puppet Users
(editor doens't have color syntax , so ss)


a...@example42.com

unread,
May 2, 2018, 2:56:41 PM5/2/18
to Puppet Users
You can definitively use a Puppetfile with puppet apply.
As you already found is a matter of running r10k puppetfile install -v from your control-repo directory (where Puppetfile is placed).
You need to resolve all the dependencies by yourself in Puppetfile (r10k does not do that for you), so list explicitly in Puppetfile all the modules you need, with their dependencies.

With the proper options, you can run puppet apply for a whole control repo, basically reproducing on the local node what is done on a Puppet server (when an ENC is not used), in this way you can use the modules from the control repo's modules dir (populated via r10k puppetfile install) and hieradata from the defined hieradata directory.

Look here https://github.com/example42/psick/blob/production/bin/papply.sh for the needed command line parameters.

Joaquin Menchaca

unread,
May 6, 2018, 1:24:54 AM5/6/18
to Puppet Users
You guys are scary sick, like in an awesome way! :)  Thank you.

If I have a block of time, I thought of spidering through the dependency chain, parsing the dependencies in metadata.json, fetching the latest version (query the forge) in the range specified, then updating the final Puppetfile.  I think I was spoiled in Chef-land as their Berksfile, which leveraged off metadata.rb, and would resolved subsequent dependencies automatically.  When I was getting reacquainted with Puppet, I had problems getting compatible modules for Puppet 3.x, as they depended on modules, but installed the latest non-Puppet 3.x compatible ones.  It was frustrating to say the least.  The Forge wasn't a fun experience (especially trying to create ElasticSearch cluster using puppet during a job interview exercise).  Now that I have some time, it is fun getting back into things, learning how things have evolved.  Example42's  material, like the fabric tasks, are exciting.
Reply all
Reply to author
Forward
0 new messages