AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 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 "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, 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.
Configure a Python Virtual Environment for Ansible AWS - ansible collection amazon.aws — Video Tutorial
Learn to configure a Python Virtual Environment for Ansible AWS amazon.aws collection using the latest Python 3.8 and boto3 library releases.
What You'll Learn
- How to configure a Python Virtual Environment for Ansible AWS?
- Links
- Playbook
- code
- execution
- Conclusion
- Related Articles
Full Tutorial Content
How to configure a Python Virtual Environment for Ansible AWS?
Using a Python Virtual Environment is a convenient way to maintain up-to-date Python dependency of the Ansible collection amazon.aws without interfering with your Linux system.
This initial configuration sometimes is a roadblock for some AWS users to start using Ansible.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
Links
- [Ansible collection amazon.aws](https://docs.ansible.com/ansible/latest/collections/amazon/aws/index.html)
- [Python boto3](https://aws.amazon.com/it/sdk-for-python/)
Playbook
Configure a Python Virtual Environment for Ansible AWS:
- boto3
How to Python Virtual Environment for Ansible AWS.
I’m going to show you how to configure a Python Virtual Environment for Ansible AWS to successfully use the Ansible collection `amazon.aws` of modules and plugins to manage various operations related to AWS infrastructure such as EC2, VPC, Security Groups, etc.
Ansible AWS modules are written on top of `boto3`. Boto3 is the Python SDK for the AWS that allows users to manage AWS infrastructure: EC2, VPC, Security Groups, etc.
code
```bash
$ python3.8 -m venv venv
$ source venv/bin/activate
(venv) $ pip3.8 install --upgrade pip
(venv) $ pip3.8 install boto3
(venv) $ ansible-galaxy collection install amazon.aws
```
execution
```bash
$ ansible --version
ansible [core 2.12.2]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/devops/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.8/site-packages/ansible
ansible collection location = /home/devops/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.8.12 (default, Sep 16 2021, 10:46:05) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
jinja version = 2.10.3
libyaml = True
[devops@demo ~]$ whereis python
python: /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python3.8 /usr/lib/python3.6 /usr/lib/python3.8 /usr/lib64/python3.6 /usr/lib64/python3.8 /usr/local/lib/python3.8 /usr/include/python3.6m /usr/include/python3.8 /usr/share/man/man1/python.1.gz
[devops@demo ~]$ python3.8 -m venv venv
[devops@demo ~]$ source venv/bin/activate
(venv) [devops@demo ~]$ pip3.8 install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/96/2f/caec18213f6a67852f6997fb0673ae08d2e93d1b81573edb93ba4ef06970/pip-22.1.2-py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 19.3.1
Uninstalling pip-19.3.1:
Successfully uninstalled pip-19.3.1
Successfully installed pip-22.1.2
(venv) [devops@demo ~]$ pip3.8 install boto3
Collecting boto3
Downloading boto3-1.24.27-py3-none-any.whl (132 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 132.5/132.5 kB 392.0 kB/s eta 0:00:00
Collecting botocore<1.28.0,>=1.27.27
Downloading botocore-1.27.27-py3-none-any.whl (9.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 3 min
- Category: installation
Read the full written article: Configure a Python Virtual Environment for Ansible AWS - ansible collection amazon.aws