Created
July 19, 2016 21:17
-
-
Save jbergstroem/6e5e8a5e1668986f92202a657baf6335 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
| try: | |
| from ansible.inventory.ini import InventoryParser | |
| except ImportError: | |
| try: | |
| # homebrew likes to mess around with PYTHONPATH | |
| # just try to parse out the homebrew stuff and fail miserably otherwise | |
| results = [re.match(r'PYTHONPATH="(.*?)"', line) | |
| # needs to open ansible from $path | |
| for line in open('/usr/local/bin/ansible')] | |
| # Remove lines that contains no matches | |
| match = [_f for _f in results if _f] | |
| # Append paths to PYTHONPATH | |
| [sys.path.append(m) for m in match[0].group(1).split(":")] | |
| from ansible.inventory.ini import InventoryParser | |
| except: | |
| print("Sorry, couldn't find Ansible.") | |
| sys.exit(1) | |
| from ansible.parsing.dataloader import DataLoader |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment