How to install Terraform, Ansible, AWS, Azure, GCP CLI for Ubuntu

    Installing Terraform, Ansible, AWS CLI, Azure CLI, and GCP CLI on Ubuntu involves using package managers and specific installation methods for each tool.

    Terraform CLI install

    • Update system packages and install dependencies.
    • Add the HashiCorp GPG key and repository.
    • Update package lists and install Terraform.
    • Verify the installation with terraform -version.

    REF:- https://developer.hashicorp.com/terraform/install

    wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
    sudo apt update -y && sudo apt install terraform -y
    terraform --version
    Bash

    Ansible CLI install

    • Add the Ansible PPA and update package lists.
    • Install Ansible using sudo apt install -y ansible.
    • Verify the installation with ansible --version.

    REF:- https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html

    Use following command to install ansible on ubuntu

    sudo apt update -y && sudo apt upgrade -y
    sudo apt install software-properties-common -y
    sudo apt-add-repository --yes --update ppa:ansible/ansible
    sudo apt install ansible -y
    ansible --version
    Bash

    check ansible dev tools installed correctly

    sudo apt install pipx -y
    pipx install ansible-dev-tools
    pipx ensurepath
    adt --version
    Bash

    AWS CLI install

    • Install unzip and curl.
    • Download and extract the AWS CLI installer.
    • Run the installer and verify with aws --version

    REF:- https://docs.aws.amazon.com/cli/v1/userguide/install-linux.html

    sudo apt update -y && sudo apt upgrade -y
    sudo apt install unzip curl -y
    curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
    unzip awscli-bundle.zip
    sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
    Bash

    OR

    sudo python3 awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
    Bash

    Azure CLI Install

    • Install with one command
      • Download and run the installer script.

    REF:- https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?view=azure-cli-latest&pivots=apt

    curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
    az --version
    Bash

    GCP CLI Install

    • Add the GCP CLI distribution URI as a package source.
    • Acquire the Google Cloud public key.
    • Update package lists and install Google Cloud CLI.
    • Verify with gcloud --version and initialize the CLI with gcloud init.

    REF:- https://cloud.google.com/sdk/docs/install#deb

    sudo apt-get update -y
    sudo apt-get install apt-transport-https ca-certificates gnupg curl -y
    curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
    cho "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
    sudo apt-get update -y && sudo apt-get install google-cloud-cli -y
    gcloud --version
    Bash


    Discover more from Altgr Blog

    Subscribe to get the latest posts sent to your email.

    Leave a Reply

    Your email address will not be published. Required fields are marked *