Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2012 03:40
Show Gist options
  • Save anonymous/4324790 to your computer and use it in GitHub Desktop.
Save anonymous/4324790 to your computer and use it in GitHub Desktop.
Ansible site_facts module written in bash
#!/bin/bash
fact_apt_updated_recently=` \
find / -maxdepth 1 -name .apt_updated -mtime 0 | wc -l | \
sed 's/0/false/' | sed 's/1/true/'
`
fact_internet_accessible=` \
ping google.com -c1 -W3 &>/dev/null && echo 'true' || echo 'false'
`
cat << EOF
{
"changed": false,
"ansible_facts": {
"site_facts_gathered": true,
"apt_updated_recently": $fact_apt_updated_recently,
"internet_accessible": $fact_internet_accessible
}
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment