Last active
April 12, 2018 19:15
-
-
Save edwardgalligan/5f7a43a3532aa3ae384d4339462898e9 to your computer and use it in GitHub Desktop.
ansible gather facts
This file contains 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
#!/usr/bin/env bash | |
# Usage: ./gather-facts.sh {{SERVER-IP}} {{SERVER-USERNAME}} > facts.json | |
# Or just copy paste from below... | |
SERVER_IP=$1 | |
SSH_USERNAME=$2 | |
printf "[hn]\n$SERVER_IP ansible_user=$SSH_USERNAME" > ansible_hosts_file.tmp && \ | |
ansible -i ansible_hosts_file.tmp -m setup hn && \ | |
rm ansible_hosts_file.tmp | |
# Assumptions: | |
# | |
# 1. Your ssh agent has access to the server | |
# 2. You are running an ssh agent | |
# 3. You are reading these assumptions in reverse order |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment