Just needed a fast way to set up facts
with a couple of commands on
the machine where I'm using/testing puppet manifests.
Surprissingly I found what I was looking for digging in Vagrant
code. Put your facts in environment variables, prefixed with
'FACTER_
':
# Define your facts as variables
export FACTER_YOURCUSTOMFACT=value1
export FACTER_OTHERFACT=value2
puppet apply /path/to/puppet/test/main.pp
Happy testing!
Background
I'm using vagrant to manage my development VMs and puppet to provision their internals.
To reuse some of the manifests, there are some variables to customize the behaviour of the manifests depending on the context. The context is managed with facts.
What if you want to define your own facts for testing some manifests? I couldn't find on the web an easy way to do it. It seems that most of the puppet documentation is related to agent/master use cases, and not my particular minimalistic setup without a master.