This document describes how to install tools such as Teraform, Ansible, and Packer.
The simplest way to install on macOS is with Homebrew. The disadvantage is that you are installing software globally on your machine, and you can end up with version conflicts across different projects.
Because of this, we generally use ASDF to manage dependencies, allowing each project have its own versions.
Python is needed to run Ansible, the AWS CLI and scripts which use boto. You can use the Python which comes with MacOS or Python 2/3 from Homebrew. We normally use ASDF to install Python 3, and we install Ansible and AWS CLI using pip. See the Ansible and AWS docs for other options.
For even more isolation, you can install Python libraries in a virtualenv.
On macOS, first install Homebrew .
brew install jq pwgenbrew install terraform
brew install terragrunt
brew install packerInstall Python dependencies, including ansible and awscli.
Change to the ansible directory and run:
python -m pip install -r requirements.txtFollow the installation instructions or use this script to install ASDF on MacOS.
After installing, log out of your shell and log back in to activate the scripts
in ~/.bashrc.
ASDF looks at the .tool-versions file and automatically sets the
path to point to the specified versions.
First install the plugins for the tools:
asdf plugin add terraform
asdf plugin add terragrunt
asdf plugin add packerInstall pacackages:
asdf installasdf plugin add python
asdf installInstall libraries into the ASDF version:
python -m pip install -r requirements.txtWhen you use pip to install a module like Ansible that has executables, you
need to run asdf reshim python to put the binary in your path.
asdf reshim pythonTo isolate the python libraries used by one project from another, you can create a virtualenv, a private project-specific directory for python libraries. This applies whether you are using ASDF or not.
In the ansible directory:
For Python 3.x:
# Create virtualenv
python3 -m venv ~/.virtualenvs/deploy
# Activate it
source ~/.virtualenvs/deploy/bin/activate
# Install libraries into it
python3 -m pip install -r requirements.txtor for Python 2.x:
# Create virtualenv
virtualenv ~/.virtualenvs/deploy
# Activate it
source ~/.virtualenvs/deploy/bin/activate
# Install libraries into it
python -m pip install -r requirements.txtLater, when running the commands, activate the virtual environment first, putting it first on your path.
source ~/.virtualenvs/deploy/bin/activate