Skip to content

Instantly share code, notes, and snippets.

@groob
Last active February 27, 2018 22:43
Show Gist options
  • Save groob/fecaec8ba448bad9998d to your computer and use it in GitHub Desktop.
Save groob/fecaec8ba448bad9998d to your computer and use it in GitHub Desktop.
Puppet-Managedmac

Sample Puppet Deployment using r10k, dynamic environments and hiera to manage macs. No puppet master needed.

This example uses dayglojesus's 'managedmac' module: https://github.com/dayglojesus/managedmac which is well documented here. http://dayglojesus.github.io/managedmac/

The Hiera data is public here (with scrambled passwords etc): https://github.com/groob/hieradata_public

The environment repo is here: https://github.com/whitby/puppet-environment

Install and Run

# Step 1 install puppet, facter and hiera on a mac
# Step 2 install these gems
# r10k required to deploy the modules
# CFPropertyList and sqlite3 gems needed by the managedmac module

sudo /usr/bin/gem install r10k CFPropertyList sqlite3

# step 3 r10k will read the r10k.yaml config file and deploy the correct repositiories into /etc/puppet/

sudo r10k deploy environment -c ./r10k.yaml -pv

# hiera.yaml needs to be in the right place for puppet to read data from hiera.

sudo ln -s /etc/puppet/environments/production/hiera.yaml /etc/puppet/hiera.yaml

# use puppet apply

sudo /usr/bin/puppet apply -v --environment production --environmentpath=/etc/puppet/environments /etc/puppet/environments/production/manifests/site.pp --debug

More info:

In our environment I tag each machine with a custom fact like "role=teacher_laptop". hiera uses %{role} in it's hierarchy.

:cachedir: '/etc/puppet/r10k_cache'
:sources:
:plops:
remote: 'https://github.com/whitby/puppet-environment'
basedir: '/etc/puppet/environments'
purge: true
:hiera:
remote: 'https://github.com/groob/hieradata_public'
basedir: '/etc/puppet/hieradata'
purge: true
@arubdesu
Copy link

One note re: sqlite3 gem, needed to run sudo xcodebuild -license to have it properly build native extensions(I was avoiding installing GUI Xcode and accepting the EULA that way)

@groob
Copy link
Author

groob commented Jul 19, 2014

Which OS? I'm using 10.9 and have had no problems installing the gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment