christiangda.awscli
Ansible Role: christiangda.awscli
This role installs the AWS Command Line Interface (awscli).
The easiest way to install this role is by running ansible-galaxy install christiangda.awscli
. You can find it in the Ansible Galaxy repository at christiangda.awscli.
The code repository is located at https://github.com/christiangda/ansible-role-awscli.
Notes:
- This role does not configure the AWS CLI profile (config and credentials). To configure it, you will need to use the christiangda.awscli_configure role.
Requirements
This role works on RedHat, CentOS, Debian, and Ubuntu systems:
- RedHat: 7, 8
- CentOS: 7, 8
- Ubuntu: 16., 18., 20., 21.
- Debian: stretch (9), buster (10), bullseye (11)
Check the compatibility of Python and Ansible in the Travis-CI build matrix.
Role Variables
No variables needed.
Dependencies
- RedHat/CentOS: You need to enable the EPEL Repository (EPEL Repository). You can use the christiangda.epel_repo role to do this.
Note: RedHat/CentOS 8 does not require the EPEL Repository for this role.
Example Playbook
For RedHat/CentOS, Ubuntu, and Debian
For RedHat/CentOS 8 or Debian/Ubuntu:
- hosts: redhat-8
gather_facts: True
roles:
- role: christiangda.awscli
For RedHat/CentOS 6/7:
- hosts: redhat-7
gather_facts: True
roles:
- role: christiangda.epel_repo
- role: christiangda.awscli
If you have multiple OS targets, install the EPEL repository only for RedHat/CentOS 6/7:
- hosts: servers
gather_facts: True
roles:
- role: christiangda.epel_repo
when: >
ansible_os_family == 'RedHat' and (
ansible_distribution == 'CentOS' or
ansible_distribution == 'RedHat'
)
and (
ansible_distribution_major_version == '6' or
ansible_distribution_major_version == '7'
)
changed_when: false
- role: christiangda.awscli
If you have RedHat/CentOS 8 or Debian/Ubuntu, and want to use the role christiangda.awscli:
- hosts: redhat-8
gather_facts: True
roles:
- role: christiangda.awscli
- role: christiangda.awscli_configure
vars:
awscliconf_files:
credentials:
- default:
aws_access_key_id: 'AKIAIOSFODNN7EXAMPLE'
aws_secret_access_key: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
config:
- default:
region: us-west-2
output: json
- profile development:
role_arn: 'arn:aws:iam::123456789012:role/role-for-development'
mfa_serial: 'arn:aws:iam::11111111111:mfa/christian.gonzalez'
region: eu-west-1
source_profile: default
Development / Contributing
This role is tested using Molecule and developed using Python Virtual Environments.
Main git branches:
- master
- develop
To contribute:
- Fork the project
- Prepare your environment
- Fix the issue in the
develop
branch - Run
molecule test
- Create a Pull Request to the official project's
develop
branch
References for help:
Prepare your environment
Make sure you have Python 3 installed. Then execute:
mkdir ansible-roles
cd ansible-roles/
python3 -m venv venv
source venv/bin/activate
pip install pip --upgrade
pip install ansible
pip install molecule
pip install 'molecule[docker]'
pip install 'molecule[lint]'
pip install molecule-vagrant
pip install python-vagrant
pip install selinux
pip install docker
pip install pytest
pip install pytest-mock
pip install pylint
pip install rope
pip install autopep8
pip install yamllint
pip install flake8
pip install ansible-lint
Clone the role repository (From your fork) and create a symbolic link:
git clone https://github.com/christiangda/ansible-role-awscli.git
ln -s ansible-role-awscli christiangda.awscli
cd christiangda.awscli
Execute the molecule test
Available scenarios:
- default -->
--driver-name docker
and it targets the latest version of the OS - docker -->
--driver-name docker
- podman -->
--driver-name podman
- vagrant -->
--driver-name vagrant
For the default scenario:
Run images step by step:
molecule create [--scenario-name default]
molecule converge [--scenario-name default]
molecule verify [--scenario-name default]
molecule destroy [--scenario-name default]
Or perform all steps in one command:
molecule test [--scenario-name default]
For the podman scenario:
Step by step:
molecule create --scenario-name podman
molecule converge --scenario-name podman
molecule verify --scenario-name podman
molecule destroy --scenario-name podman
Or all in one:
molecule test --scenario-name podman
For the vagrant scenario:
Step by step:
molecule create --scenario-name vagrant
molecule converge --scenario-name vagrant
molecule verify --scenario-name vagrant
molecule destroy --scenario-name vagrant
Or all in one:
molecule test --scenario-name vagrant
If you wish to test using VMs, check out my ansible-playground project that utilizes Vagrant and VirtualBox.
License
This module is licensed under the GNU General Public License Version 3:
Author Information
Ansible Role for AWS Command Line Interface (awscli)
ansible-galaxy install christiangda.awscli