How To Install PIP Using Ansible ? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Nowadays the IT culture is evolving with Agile practices and DevOps Culture, on idea of making the business plans, and features quickly to market and making users available. In this software development workflow configuring software and updating the patches to each system manually or through automation is time-consuming. In resolving this kind of problem ansible comes into play. Ansible works agentless with push-based mechanism that facilitates configuring the worker nodes that are connected to it remotely with the help of playbooks and ad-hoc commands. Understanding Of Primary TerminologiesAnsible: An open-source automating configuration management tool that is used for application deployment and task automation.Playbook: It is a file with YAML syntax that used in defining a set of tasks and configurations that is executed by Ansible on remote hosts.Inventory: It is a file that contains a list of hosts that are the worker nodes details that are used by Ansible manager for ensuring worker nodes that can be static or dynamically generated.Module: A discrete unit of code in Ansible responsible for performing specific tasks on managed nodes, such as installing packages or copying files.Task: A Task is a single unit of work defined within an Ansible playbook, representing an action to be executed on a remote host.Worker Node: A node in a distributed computing environment responsible for executing tasks or workloads, often part of a cluster managed by tools like Kubernetes or Hadoop.How To Install pip Using Ansible Playbook: A Step-By-Step GuideIn this implementation we taking 3 aws instances with Amazon linux AMI, (you can also choose other AMI also) as One Manager Node and 2 Worker Nodes. Here we define the details and credentials in inventory and install the pip software in worker nodes through running the playbook for it in manager node. Step 1: Create InstancesNavigate To AWS Management Console and sign with your Credentials. Navigate To EC2 Dashboard And Click On Launch Instances. Firstly lets create Ansible Manager Node. Provide the name of the instance as "Ansible Manger Node" , Number of Instances as "1" and choose the AMI as "Amazon Linux". Step 2: Configure SSH Key And Security GroupsChoose The available key pair in your PC, if you don't have create one pem file. Make sure the choosen pem file available in your local laptop. Configure the Security Groups with providing the all accesses such as Allowing traffic , protocols and ports, so that we don't face any security restrictions from the AWS Instance. The following screenshot illustrates it clearly. After Configuring the security groups checking the defined values once and click on launch instance as confirmation.Step 3: Running InstancesAfter launching the instance, it takes some time to come for running state. Here we guided you to create Ansible Manager Node perform step 1 and step 2 again to create 2 worker nodes with name such as "Ansible Worker Node 1" and "Ansible Worker Node 2" with choosing same key pair file that choosen for Manager Node.The following screenshot shows successful running of all these 3 Instances. Step 4: Connect Manager NodeNow, Connect to Ansible Manager Node by checking the instance and clicking on Connect button as shown in below screenshot. Step 5: Connect EC2 ConsoleAfter coming to the Ansible Manager Node instance go to the EC2 Instance Connect section and then click on Connect Button. Step 6: Install AnsibleOn accessing the EC2 Console, now install the ansible software with the following command:yum install ansible -y Step 7: Verify AnsibleAfter installing the ansible software, verify it successfully installed or not with checking the ansible version by following command:ansible --version Step 8: Copy Pem fileNow, Come to your laptop open the choosen/dowloaded pem key file and copy the key as shown in the below screenshot. Step 9: Adding Permission To Pem FileSave the pem file to your instance as shown in the screenshot below with file name "myssh_key.pem" Now, provide the only read permission to the user for making the pem file more secured with the following command:chmod 400 myssh_key.pemStep 10: Create InventoryCreate an inventory with hosts file name and specify the worker ip and credentials as shown in the below screenshot. Step 11: Ping The Worker NodesAfter creating the inventory file with hosts as filename, check the connecting with the worker nodes with the following command:ansible -i hosts all -m pingThe following screenshot illustrates clearly that our worker nodes are successfully pinging. To check the connectivity with ping on ignoring the warning use the following command with -o option as follows:ansible -i hosts all -m -o ping Step 12: Define PlaybookNow create a create playbook file such as naming with myplaybook.yml and define the following code in it.---- name: Install pip on Amazon Linux hosts: your-instance-public-ip become: true tasks: - name: Update package cache yum: name: '*' state: latest become: true - name: Install Python and pip yum: name: "{{ item }}" state: present become: true loop: - python3 - python3-pipThe following illustrates the same with practical screenshot. Step 13: Run The PlaybookNow, run the defined playbook with the following command:ansible-playbook -i hosts myplaybook.yml The following screenshot illustrates running of the playbook. On getting the output of the playbook run process as shown in the below screenshot indicates we successfully installed the pip software in the worker nodes. Step 14: Verify The Software In Worker NodesTo Cross check the installation of pip software in the worker nodes, navigate to EC2 Dashboard and connect to EC2 Console of worker node and run the following command: pip --versionThe following screenshot illustrates successful installation of pip software in the Ansible worker Node 1. The following screenshot illustrates successful installation of pip software in the Ansible worker Node 2. Finally, we have successfully implemented the installation of python and Pip softwares on worker nodes from the Ansible manager node using ansible playbook. Comment More infoAdvertise with us Next Article What is DevOps ? K kattagopi6174 Follow Improve Article Tags : DevOps Dev Scripter Ansible Dev Scripter 2024 Similar Reads DevOps Tutorial DevOps is a combination of two words: "Development" and "Operations." Itâs a modern approach where software developers and software operations teams work together throughout the entire software life cycle.The goals of DevOps are:Faster and continuous software releases.Reduces manual errors through a 7 min read IntroductionWhat is DevOps ?DevOps is a modern way of working in software development in which the development team (who writes the code and builds the software) and the operations team (which sets up, runs, and manages the software) work together as a single team.Before DevOps, the development and operations teams worked sepa 10 min read DevOps LifecycleThe DevOps lifecycle is a structured approach that integrates development (Dev) and operations (Ops) teams to streamline software delivery. It focuses on collaboration, automation, and continuous feedback across key phases planning, coding, building, testing, releasing, deploying, operating, and mon 10 min read The Evolution of DevOps - 3 Major Trends for FutureDevOps is a software engineering culture and practice that aims to unify software development and operations. It is an approach to software development that emphasizes collaboration, communication, and integration between software developers and IT operations. DevOps has come a long way since its in 7 min read Version ControlVersion Control SystemsA Version Control System (VCS) is a tool used in software development and collaborative projects to track and manage changes to source code, documents, and other files. Whether you are working alone or in a team, version control helps ensure your work is safe, organized, and easy to collaborate on. 5 min read Merge Strategies in GitIn Git, merging is the process of taking the changes from one branch and combining them into another. The merge command in Git will compare the two branches and merge them if there are no conflicts. If conflicts arise, Git will ask the user to resolve them before completing the merge.Merge keeps all 4 min read Which Version Control System Should I Choose?While building a project, you need a system wherein you can track the modifications made. That's where Version Control System comes into the picture. It came into existence in 1972 at Bell Labs. The very first VCS made was SCCS (Source Code Control System) and was available only for UNIX. When any p 5 min read Continuous Integration (CI) & Continuous Deployment (CD)What is CI/CD?CI/CD stands for Continuous Integration and Continuous Delivery/Deployment. It is the practice of automating the integration of code changes from multiple developers into a single codebase. It is a software development practice where the developers commit their work frequently to the central code re 6 min read Understanding Deployment AutomationIn this article we will discuss deployment automation, categories in Automated Deployment, how automation can be implemented in deployment, how it is assisting DevOps and finally the benefits and drawbacks of Deployment Automation. So, let's start exploring the topic in detail. Deployment Automation 4 min read ContainerizationWhat is Docker?Have you ever wondered about the reason for creating Docker Containers in the market? Before Docker, there was a big issue faced by most developers whenever they created any code that code was working on that developer computer, but when they try to run that particular code on the server, that code 12 min read What is Dockerfile Syntax?Pre-requsites: Docker,DockerfileA Dockerfile is a script that uses the Docker platform to generate containers automatically. It is essentially a text document that contains all the instructions that a user may use to create an image from the command line. The Docker platform is a Linux-based platfor 5 min read Kubernetes - Introduction to Container OrchestrationIn this article, we will look into Container Orchestration in Kubernetes. But first, let's explore the trends that gave rise to containers, the need for container orchestration, and how that it has created the space for Kubernetes to rise to dominance and growth. The growth of technology into every 4 min read OrchestrationKubernetes - Introduction to Container OrchestrationIn this article, we will look into Container Orchestration in Kubernetes. But first, let's explore the trends that gave rise to containers, the need for container orchestration, and how that it has created the space for Kubernetes to rise to dominance and growth. The growth of technology into every 4 min read Fundamental Kubernetes Components and their role in Container OrchestrationKubernetes or K8s is an open-sourced container orchestration technology that is used for automating the manual processes of deploying, managing and scaling applications by the help of containers. Kubernetes was originally developed by engineers at Google and In 2015, it was donated to CNCF (Cloud Na 12 min read How to Use AWS ECS to Deploy and Manage Containerized Applications?Containers can be deployed for applications on the AWS cloud platform. AWS has a special application for managing containerized applications. Elastic Container Service (ECS) serves this purpose. ECS is AWS's container orchestration tool which simplifies the management of containers. All the containe 4 min read Infrastructure as Code (IaC)Infrastructure as Code (IaC)Infrastructure as Code (IaC) is a method of managing and provisioning IT infrastructure using code rather than manual configuration. It allows teams to automate the setup and management of their infrastructure, making it more efficient and consistent. This is particularly useful in the DevOps enviro 6 min read Introduction to TerraformMany people wonder why we use Terraform when there are already so many Infrastructure as Code (IaC) tools out there. So, before learning Terraform, letâs understand why it was created.Terraform was made to solve some common problems with existing IaC tools. Some tools, like AWS CloudFormation, only 15 min read What is AWS Cloudformation?Amazon Web Services(AWS) offers cloud formation as a service by which you can provision and manage complicated services offered by AWS by using the code. CloudFormation will help you to manage the infrastructure and the services in the form of a declarative way. Table of ContentIntroduction to AWS C 14 min read Monitoring and LoggingWorking with Prometheus and Grafana Using HelmPre-requisite: HELM Package Manager Helm is a package manager for Kubernetes that allows you to install, upgrade, and manage applications on your Kubernetes cluster. With Helm, you can define, install, and upgrade your application using a single configuration file, called a Chart. Charts are easy to 5 min read Working with Monitoring and Logging ServicesPre-requisite: Google Cloud Platform Monitoring and Logging services are essential tools for any organization that wants to ensure the reliability, performance, and security of its systems. These services allow organizations to collect and analyze data about the health and behavior of their systems, 5 min read Microsoft Teams vs Slack Both Microsoft Teams and Slack are the communication channels used by organizations to communicate with their employees. Microsoft Teams was developed in 2017 whereas Slack was created in 2013. Microsoft Teams is mainly used in large organizations and is integrated with Office 365 enhancing the feat 4 min read Security in DevOpsWhat is DevSecOps: Overview and ToolsDevSecOps methodology is an extension of the DevOps model that helps development teams to integrate security objectives very early into the lifecycle of the software development process, giving developers the team confidence to carry out several security tasks independently to protect code from adva 10 min read DevOps Best Practices for KubernetesDevOps is the hot topic in the market these days. DevOps is a vague term used for wide number of operations, most agreeable defination of DevOps would be that DevOps is an intersection of development and operations. Certain practices need to be followed during the application release process in DevO 11 min read Like