Skip to content

Instantly share code, notes, and snippets.

@edwardgalligan
Last active April 12, 2018 19:15
Show Gist options
  • Save edwardgalligan/5f7a43a3532aa3ae384d4339462898e9 to your computer and use it in GitHub Desktop.
Save edwardgalligan/5f7a43a3532aa3ae384d4339462898e9 to your computer and use it in GitHub Desktop.
ansible gather facts
#!/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