Skip to content

Instantly share code, notes, and snippets.

@tmclnk
Created September 6, 2019 22:19
Show Gist options
  • Save tmclnk/b9bbe3d69885de4d1dc5877ae8f02f00 to your computer and use it in GitHub Desktop.
Save tmclnk/b9bbe3d69885de4d1dc5877ae8f02f00 to your computer and use it in GitHub Desktop.
Ansible EC2 inventory on Mac
################################################################################
# When you need to run the AWS inventory tasks from ansible on
# a Mac Mojave, you may run into environment issues, especially if you're
# like me and can't remember whether or not to run pip as root,
# which pip to run, and which tools require python2 vs python3.
#
# With ansible, I've stopped using homebrew as the installer,
# and instead install it with pip.
#
# Use the python virtualenv mechanism to set up python dependencies,
# it's well worth the effort.
################################################################################
# General Troubleshooting for Python on Mac
#
# If you messed up permissions somewhere by running pip/pip3 as root,
# chown -R $USER ~/Library/Caches/pip
# chown -R $USER ~/Library/Python
#
# With Python 3.7:
#
# If you have issues with the cryptography package, you may need to expose the
# openssl libs and headers
# pip install -r requirements.txt --global-option=build_ext \
# --global-option="-L/usr/local/opt/openssl/lib" \
# --global-option="-I/usr/local/opt/openssl/include"
#
# enum34 will break on Python > 3.4, so use enum-compat==0.0.2
# PyYAML<3.13 will break in Python 3.7, so use PyYAML==3.13
################################################################################
# For Python 3:
# Begin by install virtualenv
pip3 install virtualenv
# Have virtualenv create a python install in some directory, here
# we're calling it venv
virtualenv venv
# this will create a python install in "venv/"
# source "activate" to modify your path so the preferred python is first
# this will also alter your shell prompt for the duration
source venv/bin/activate
# if you happen to have a requirements.txt, you can install with
pip install -r requirements.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment