Created
October 23, 2012 18:57
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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