While working on one of the client's project I wanted to install and use Microsoft Azure-cli to manage Azure cloud on ubuntu (Get Started: Configure Ansible for Azure Cloud Infrastructure). This is step by step guide, First step I am updating and upgrading ubuntu system using apt-get.
vjanvi@ubuntu2004:~$ sudo su - root@ubuntu2004:~# root@ubuntu2004:~# sudo apt-get update Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease Hit:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease Hit:3 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease Reading package lists... Done root@ubuntu2004:~# root@ubuntu2004:~# sudo apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following package was automatically installed and is no longer required: libfwupdplugin1 Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. root@ubuntu2004:~#
Install additional necessary packages ca-certificates, curl apt-transport-https, lsb-release, gnupg using apt-get.
root@ubuntu2004:~# sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg
Reading package lists... Done
Building dependency tree
Reading state information... Done
lsb-release is already the newest version (11.1.0ubuntu2).
lsb-release set to manually installed.
ca-certificates is already the newest version (20210119~20.04.2).
ca-certificates set to manually installed.
curl is already the newest version (7.68.0-1ubuntu2.7).
gnupg is already the newest version (2.2.19-3ubuntu2.1).
gnupg set to manually installed.
The following package was automatically installed and is no longer required:
libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
apt-transport-https
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,680 B of archives.
After this operation, 162 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 apt-transport-https all 2.0.6 [4,680 B]
Fetched 4,680 B in 0s (39.1 kB/s)
Selecting previously unselected package apt-transport-https.
(Reading database ... 189894 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_2.0.6_all.deb ...
Unpacking apt-transport-https (2.0.6) ...
Setting up apt-transport-https (2.0.6) ...
root@ubuntu2004:~#
Download and install the Microsoft signing key, Add the Azure CLI software repository and Update repository information.
root@ubuntu2004:~# curl -sL https://packages.microsoft.com/keys/microsoft.asc | > gpg --dearmor | > sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null root@ubuntu2004:~# root@ubuntu2004:~# AZ_REPO=$(lsb_release -cs) root@ubuntu2004:~# echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | > sudo tee /etc/apt/sources.list.d/azure-cli.list deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ focal main root@ubuntu2004:~# root@ubuntu2004:~# sudo apt-get update Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease Hit:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease Hit:3 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease Get:4 https://packages.microsoft.com/repos/azure-cli focal InRelease [10.4 kB] Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] Get:6 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages [8,439 B] Fetched 133 kB in 1s (90.8 kB/s) Reading package lists... Done root@ubuntu2004:~#
You can install specific version of azure-cli. To list versions use below command, to install version use command sudo apt-get install azure-cli=<version>-1~focal.
root@ubuntu2004:~# apt-cache policy azure-cli
azure-cli:
Installed: (none)
Candidate: 2.34.1-1~focal
Version table:
2.34.1-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.34.0-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.33.1-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.33.0-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.32.0-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.31.0-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.30.0-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.29.2-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.29.1-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.29.0-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.28.0-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.27.2-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
2.27.1-1~focal 500
500 https://packages.microsoft.com/repos/azure-cli focal/main amd64 Packages
To install latest version use below apt-get command.
root@ubuntu2004:~#
root@ubuntu2004:~# sudo apt-get install azure-cli
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
azure-cli
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/75.4 MB of archives.
After this operation, 1,083 MB of additional disk space will be used.
Selecting previously unselected package azure-cli.
(Reading database ... 189893 files and directories currently installed.)
Preparing to unpack .../azure-cli_2.34.1-1~focal_all.deb ...
Unpacking azure-cli (2.34.1-1~focal) ...
Setting up azure-cli (2.34.1-1~focal) ...
root@ubuntu2004:~#
Finally test the az command check installed version, its successful. To login and set the default subscription check article Get Started: Configure Ansible for Azure Cloud Infrastructure.
root@ubuntu2004:~# az version
{
"azure-cli": "2.34.1",
"azure-cli-core": "2.34.1",
"azure-cli-telemetry": "1.0.6",
"extensions": {}
}
root@ubuntu2004:~#
Incase if you are using proxy server, use below command to get apt-get installation working.
# No auth export HTTP_PROXY=http://[proxy]:[port] export HTTPS_PROXY=https://[proxy]:[port] # Basic auth export HTTP_PROXY=http://[username]:[password]@[proxy]:[port] export HTTPS_PROXY=https://[username]:[password]@[proxy]:[port]
For permanent configuration of apt-get to use proxy server configure /etc/apt/apt.conf.d/apt.conf file with below configuration.
Acquire { http::proxy "http://[username]:[password]@[proxy]:[port]"; https::proxy "https://[username]:[password]@[proxy]:[port]"; }
Useful Articles
Ansible selectattr The error was TemplateRuntimeError no test named 'equalto'
ansible create an array with set_fact
Ansible get information from esxi advanced settings nested dictionary with unique keynames
Install Ansible AWX Tower on Ubuntu Linux
Ansible AWX installation error Cannot have both the docker-py and docker python modules
Ansible AWX installation error docker-compose run --rm --service-ports task awx-manage migrate --no-input
docker: Got permission denied while trying to connect to the Docker daemon socket
Ansible AWX Tower create Manual SCM (Source Control Credential Type) project
Reset Ansible AWX Tower admin password
Install Ansible AWX on Microsoft Windows OS
Step by Step Install Ansible on Ubuntu OS
Install Ansible AWX Tower on Ubuntu Linux OS
Ansible AWX Tower Github inventory integration | Github inventory source