ppa:ansible/ansible repository
sudapt-add-repository -y ppa:ansible/ansible
sudapt-get update
sudapt-get install -y ansible
This installs Ansible globally.
Virtualenv's
This is my preferred way to install Ansible.
We can also use Pip to install virtualenv, which lets us install Python libraries in their own little environment that won't affect others (nor force us to install tools globally).
Here's how:
# Install python2.7 (Ubuntu 16.04 comes with python 3 out of the box) and Pip
sudo apt-get install -y python2.7 python-pip
## Use Pip to install virtualenv
### -U updates it if the package is already installed
sudo pip install -U virtualenv
Once we have pip and virtualenv installed globally, we can get Ansible inside of a virtual environment:
# Go to my user's home directory,
# make a directory to play with ansible
cd ~/
mkdir ansible-play
cd ansible-play
# Create a python virtual environment
virtualenv .venv
# Enable the virtual environment
source .venv/bin/activate
# Then anything we intall with pip will be
# inside that virtual environment
pip install ansible
Those commands will install the latest stable Ansible 2 (as of this writing).
Later, when you're done, you can deactivate the virtualenv via the deactivate command
At any time, you can update ansible by running:
# Assumes the virtualenv is active - `source .venv/bin/activate`
# Assuming the virtualenv is active
pip install -U ansible
sudapt-add-repository -y ppa:ansible/ansible
sudapt-get update
sudapt-get install -y ansible
This installs Ansible globally.
Virtualenv's
This is my preferred way to install Ansible.
We can also use Pip to install virtualenv, which lets us install Python libraries in their own little environment that won't affect others (nor force us to install tools globally).
Here's how:
# Install python2.7 (Ubuntu 16.04 comes with python 3 out of the box) and Pip
sudo apt-get install -y python2.7 python-pip
## Use Pip to install virtualenv
### -U updates it if the package is already installed
sudo pip install -U virtualenv
Once we have pip and virtualenv installed globally, we can get Ansible inside of a virtual environment:
# Go to my user's home directory,
# make a directory to play with ansible
cd ~/
mkdir ansible-play
cd ansible-play
# Create a python virtual environment
virtualenv .venv
# Enable the virtual environment
source .venv/bin/activate
# Then anything we intall with pip will be
# inside that virtual environment
pip install ansible
Those commands will install the latest stable Ansible 2 (as of this writing).
Later, when you're done, you can deactivate the virtualenv via the deactivate command
At any time, you can update ansible by running:
# Assumes the virtualenv is active - `source .venv/bin/activate`
# Assuming the virtualenv is active
pip install -U ansible
No comments:
Post a Comment