0

I'm writing an ENC for Puppet. Currently I have a basic template which is hooked up and working:

#!/bin/bash
if [ "$1" = beta.example.com ]; then
  echo "environment: beta"
else
  echo "environment: production"
fi

The value $1 is automatically sent by the agent and gives me a unique address. I'd like to send another parameter from the agent, so that I can access the device's mac address as $2.

How can I modify the agent connection process to send extra information to my ENC?

Philip Kirkbride
  • 279
  • 2
  • 10
  • 30

1 Answers1

1

So if you are using PuppetDB, and you could use retrieve the facts from the DB via the API and make decisions on any of the facts client reported, which typically will include the physical address of active interfaces. Not sure how easy it would be to do that from a bash script though.

Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • With PuppetDB all the facts for each node are automatically recorded on connection? – Philip Kirkbride Apr 26 '17 at 20:01
  • 1
    Yes, also logs of the catalogs that were built up, and many other potential useful bits of information that is all accessible via the API using only the node's client name. – Zoredache Apr 26 '17 at 20:02
  • 1
    The facts are also written to the master's filesystem before calling the ENC, so you can read them out of the file at `/opt/puppetlabs/server/data/puppetserver/yaml/facts/beta.example.com.yaml`. – Dominic Cleal Apr 27 '17 at 07:04