Skip to content

Instantly share code, notes, and snippets.

@groob
Created August 1, 2016 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save groob/d16aa82d01a47e2714e6f5bf75067ec3 to your computer and use it in GitHub Desktop.
Save groob/d16aa82d01a47e2714e6f5bf75067ec3 to your computer and use it in GitHub Desktop.
creates puppet-tag pkg

First, create the appropriate directories like tags/some_role/hardware_tag.txt The text file, hardware_tag.txt can have any metadata you'd like, as long as it's in a format that facter will read. See https://docs.puppet.com/facter/3.1/custom_facts.html#external-facts

# hardware_tag.txt
role=labmac
building=nh
room=101
dualboot=true

Then make the package

# creates the pkg according to the makefile build instruction
make ROLE=some_role
# imports the out/puppet-tag-some_role.pkg into munki
make munki
PKGVERSION=1.0.0
PKGNAME="puppet-tag"
PKGID=com.mycompany.facter.hardware_tag
ROLE=undef
all: clean build
clean:
rm -f out/${PKGNAME}-${ROLE}-${PKGVERSION}.pkg
rm -f pkgroot/etc/facter/facts.d/hardware_tag.txt
build:
@cat tags/$(ROLE)/hardware_tag.txt > pkgroot/etc/facter/facts.d/hardware_tag.txt
mkdir -p out
pkgbuild --root pkgroot --identifier ${PKGID}.${ROLE} --version ${PKGVERSION} out/${PKGNAME}-${ROLE}-${PKGVERSION}.pkg
munki:
munkiimport --unattended-install --catalog=testing -n --subdirectory admin/puppet_tags --developer=MyCompany out/${PKGNAME}-${ROLE}-${PKGVERSION}.pkg && makecatalogs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment