AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
How to install Ansible in Amazon Linux 2 (AWS EC2) - Ansible install — Video Tutorial
How to install Ansible in Amazon Linux 2 using the Amazon Extras Library \\"amazon-linux-extras\\" and the EPEL (Extra Packages for Enterprise Linux).
What You'll Learn
- How to install Ansible in Amazon Linux 2
- Links
- Playbook
- Amazon Extras Library code
- Amazon Extras Library execution
- Amazon Extras Library after execution
- EPEL code
- EPEL execution
- EPEL after execution
- Conclusion
Full Tutorial Content
How to install Ansible in Amazon Linux version 2?
Today we're going to talk about the easier way to install and maintain Ansible inside Amazon Linux 2 using the Amazon Extras Library and EPEL repositories.
I'm Luca Berton and welcome to today's episode of Ansible Pilot.
How to install Ansible in Amazon Linux 2
- "ansible2" topic in Extras Library repository
- "ansible" in Extra Packages for Enterprise Linux (EPEL) additional packages for Enterprise Linux: Red Hat Enterprise Linux (RHEL), Rocky Linux and Scientific Linux (SL), Oracle Linux (OL), and Amazon Linux
Today we're talking about How to install Ansible in Amazon Linux 2.
The good news is that Ansible is included in the Extras Library included in Amazon Linux 2 repository using the "amazon-linux-extras" command.
Another option is to install and maintain Ansible inside Amazon Linux 2 is using the Extra Packages for Enterprise Linux (EPEL) additional repository.
This repository is maintained by the Fedora Special Interest Group and manages a high-quality set of additional packages for Enterprise Linux: Red Hat Enterprise Linux (RHEL), Rocky Linux and Scientific Linux (SL), Oracle Linux (OL), and Amazon Linux.
Links
- [Amazon Linux 2](https://aws.amazon.com/it/amazon-linux-2/)
- [How do I enable the EPEL repository for my Amazon EC2 instance running CentOS, RHEL, or Amazon Linux?](https://aws.amazon.com/it/premiumsupport/knowledge-center/ec2-enable-epel/)
- [Extras library (Amazon Linux 2)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-ami-basics.html#extras-library)
- [Extra Packages for Enterprise Linux (EPEL)](https://docs.fedoraproject.org/en-US/epel/)
Playbook
Install Ansible in Amazon Linux (EC2) 2 using the Amazon Extras Library and EPEL repositories.
Here are the steps on how to install Ansible in Amazon Linux 2 (AWS EC2):
1. Update the package list:
```bash
$ sudo yum update -y
```
2. Install the Ansible package:
```bash
$ sudo amazon-linux-extras install ansible2 -y
```
3. Check the Ansible version:
```bash
$ ansible --version
```
4. Verify that Ansible is installed correctly by running a simple playbook:
```bash
$ ansible localhost -m ping
```
This playbook will print the following output:
```bash
localhost | SUCCESS => {
"changed": false,
"ping": "pong"
}
```
If you see this output, then Ansible is installed and configured correctly.
Amazon Extras Library code
- Install-Ansible-Amazon Linux2-Amazon Extras Library.sh
```bash
#!/bin/bash
$ sudo yum update -y
$ sudo amazon-linux-extras install ansible2 -y
$ ansible --version
```
Amazon Extras Library execution
```bash
$ ssh -i key.pem ec2-user@34.241.249.206
__| __|_ )
_| ( / Amazon Linux 2 AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-2/
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
[ec2-user@ip-172-31-36-49 ~]$ sudo su
[root@ip-172-31-36-49 ec2-user]# cat /etc/image-id
image_name="amzn2-ami-ke
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 18 min
- Category: installation
Read the full written article: How to install Ansible in Amazon Linux 2 (AWS EC2) - Ansible install