-
-
Save kronn/5320216 to your computer and use it in GitHub Desktop.
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 | |
ssh_host=$1 | |
host_name=${2:-$ssh_host} | |
puppet_version="2.7.1" | |
if [ -z "$ssh_host" ]; then | |
echo "please provide hostname for node to fetch facts from" | |
exit | |
fi | |
file="features/nodes/$host_name.yaml" | |
cat > $file <<EOHEAD | |
--- !ruby/object:Puppet::Node | |
classes: [] | |
environment: &id002 production | |
name: $host_name | |
parameters: | |
clientversion: ${puppet_version}" | |
EOHEAD | |
# run facter on the remote host, remove the first line ("---"), indend the yaml under above params | |
ssh $ssh_host 'sudo facter --yaml --puppet' \ | |
| sed -e '1d' \ | |
| sed -e 's/^/ /' \ | |
>> $file | |
echo "Facts for $host_name written to $file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment