Skip to content

Instantly share code, notes, and snippets.

@niklas
Created October 23, 2012 18:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save niklas/3940817 to your computer and use it in GitHub Desktop.
Save niklas/3940817 to your computer and use it in GitHub Desktop.
Fetch facter facts from a remote host and convert to be used in cucumber-puppet
#!/bin/bash
host=$1
if [ -z "$host" ]; then
echo "please provide hostname for node to fetch facts from"
exit
fi
file="features/nodes/$host.yaml"
cat > $file <<EOHEAD
--- !ruby/object:Puppet::Node
classes: []
environment: &id002 production
name: $host
parameters:
EOHEAD
# run facter on the remote host, remove the first line ("---"), indend the yaml under above params
ssh $host 'facter --yaml --puppet' \
| sed -e '1d' \
| sed -e 's/^/ /' \
>> $file
echo "Facts for $host written to $file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment