Skip to content

Instantly share code, notes, and snippets.

@nhthai2005
Last active April 10, 2022 04:46
Show Gist options
  • Save nhthai2005/23b823d3e77b330a74d4dd8795966412 to your computer and use it in GitHub Desktop.
Save nhthai2005/23b823d3e77b330a74d4dd8795966412 to your computer and use it in GitHub Desktop.
Howto install ansible on Ubuntu
#!/bin/bash
# Howto install ansible on Ubuntu
python3 -m venv ansible
# if Debian/Ubuntu, then:
# sudo apt install python3.10-venv
# python3.10 -m venv ansible
# To access your project
source ansible/bin/activate
# Install ansible
pip install ansible
# if you want to install ansible with the specified version
# pip install ansible==2.9.9
# Add alias to .bashrc or .zshrc to activate ansible conveniently.
echo alias source-ansible=\"source $(dirname $(which ansible))/activate\" >> ~/.bashrc #if using bash
echo alias source-ansible=\"source $(dirname $(which ansible))/activate\" >> ~/.zshrc #if using zsh
# To exit your project
deactivate
# Try accessing your project with alias by closing your terminal and run the following command
source-ansible
ansible --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment