2

Is there any ready way / custom fact / etc to be able to have Puppet respond differently if a given host and port isn't available from the managed system?

For example I have some products that use multiple directories for reading user information.

Generally I'd want the fastest and closest server listed first. If it isn't available I'd like my module to be able to rewrite the config file to go to the lower entries on the list.

Tim Brigham
  • 15,465
  • 7
  • 72
  • 113

2 Answers2

2

So this is for swapping something in via a config variable in a template?

I think the best way to do this would be to write a custom fact in Ruby that does the speed and reachability testing, then use that custom fact to set the string in the template. Does that seem reasonable for your use case?

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
0

Take a look at puppet's stdlib. It allows you to put custom data or scripts in /etc/facter/facts.d (description).

So you can e.g. have a small script /etc/facter/facts.d/neighbour.sh to add a new variable to facter -p:

#! /bin/sh

if ping -nc 1 dirserver.fnqd > /dev/null; then
  echo 'dirserver_available=true'
else
  echo 'dirserver_available=false'
fi

With a little scripting you could add custom facts like dirserver_1, dirserver_2 etc. in order of latency.

mschuett
  • 3,066
  • 20
  • 21