How to install ansible on ubuntu 20.04 server

Published: 二 28 九月 2021
By jlz

In linux.

I am assuming your geo location is in China. Just copy-and-paste the following code into a bash script and execute it. It should work without any problem on a fresh installed ubuntu 20.04 server.

#!/usr/bin/env bash

apt install python3-pip

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

pip install ansible

# pip install paramiko # install paramiko only if your openssh version is too old


## 清华源
#pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
## 阿里源
#pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
## 腾讯源
#pip config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
## 豆瓣源
#pip config set global.index-url http://pypi.douban.com/simple/

The steps are:

  1. install pip
    • It seems ubuntu 20.04 has dropped support for python2, good
  2. set pip mirror.
    • There are several mirrors in China. Using these mirrors might break your security, use them at your own risk.
  3. install ansible and paramiko
    • It seems ansible is pretty easy to install.
    • ssh functionalities require paramiko if your openssh is too old

links

social