Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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