Skip to content

Instantly share code, notes, and snippets.

@jctanner
Created April 7, 2014 15:29
Show Gist options
  • Save jctanner/10022471 to your computer and use it in GitHub Desktop.
Save jctanner/10022471 to your computer and use it in GitHub Desktop.
Ansible Install Troubleshooting
#!/usr/bin/env python
import sys
import os
import hashlib
import ansible
from ansible import utils
sitedirs = []
try:
import site
sitedirs += site.getsitepackages()
except:
pass
try:
from distutils.sysconfig import get_python_lib
sitedirs.append(get_python_lib())
except:
pass
sitedirs = sorted(set(sitedirs))
installdirs = []
for path in sitedirs:
if os.path.isdir(path):
testpath = os.path.join(path, 'ansible')
if os.path.isdir(testpath):
installdirs.append(testpath)
thispath = ansible.__file__
thispath = os.path.dirname(thispath)
print "# INSTALLED LIB PATH"
print thispath
print "# OTHER INSTALLED LIB PATHS"
for path in installdirs:
print path
module_list = []
paths = utils.plugins.module_finder._get_paths()
for path in paths:
if os.path.isdir(path):
for module in os.listdir(path):
fullpath = os.path.join(path, module)
if os.path.isfile(fullpath):
module_list.append(fullpath)
print "# MODULES"
for module in sorted(module_list):
this_hash = hashlib.sha256(open(module, 'rb').read()).hexdigest()
print module,"\t",this_hash
@jctanner
Copy link
Author

jctanner commented Apr 7, 2014

Find the sha history for a file ...
git log library/cloud/ec2 | egrep ^commit | awk '{print $2}' > /tmp/commits.txt
for C in $(cat /tmp/commits.txt); do echo $C; git checkout $C; echo  "$C $(sha256sum library/cloud/ec2)" | tee -a /tmp/results.txt ; done;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment