sepiros62 / ansible-role-awscli

Ansible Role for Amazon Command Line Interface (awscli)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ansible Role: christiangda.awscli

Build Status Ansible Role

This role install AWS Command Line Interface (awscli)

The best wayt to install this role is using the command ansible-galaxy install christiangda.awscli, the Ansible Galaxy repository is christiangda.awscli

The repository code is https://github.com/christiangda/ansible-role-awscli

Notes:

Requirements

This role work on RedHat, CentOS, Debian and Ubuntu distributions

  • RedHat
    • 6
    • 7
    • 8
  • CentOS
    • 6
    • 7
    • 8
  • Ubuntu
    • 14.*
    • 16.*
    • 18.*
    • 19.*
  • Debian
    • jessie (8)
    • stretch (9)
    • buster (10)
    • sid (unstable)

To see the compatibility matrix of Python vs. Ansible see the project Travis-CI build matrix

Role Variables

None

Dependencies

Note: RedHat/CentOS 8 doesn't need EPEL Repository to use this role.

Example Playbook

RedHat/CentOS, Ubuntu and Debian

When you have RedHat/CentOS 8 or Debian/Ubuntu target

- hosts: redhat-8
    gather_facts: True
    roles:
      - role: christiangda.awscli

When you have RedHat/CentOS 6/7 target

- hosts: redhat-7
    gather_facts: True
    roles:
      - role: christiangda.epel_repo
      - role: christiangda.awscli

When you have multiples OS targets, install EPEL repository only in 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

When you have RedHat/CentOS 8 or Debian/Ubuntu target and wants 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 was developed using Python Virtual Environments

Prepare your environment

  • Python 3
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[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

Clone the role repository and create symbolic link

git clone https://github.com/christiangda/ansible-role-awscli.git
ln -s ansible-role-awscli christiangda.awscli
cd christiangda.awscli

Execute the test

Using docker in local

molecule test [--scenario-name default]

Using vagrant in local

molecule create --scenario-name vagrant
molecule converge --scenario-name vagrant
molecule verify --scenario-name vagrant

or

molecule test --scenario-name vagrant

Additionally if you want to test it using VMs, I have a very nice ansible-playground project that use Vagrant and VirtualBox, try it!.

License

This module is released under the GNU General Public License Version 3:

Author Information

About

Ansible Role for Amazon Command Line Interface (awscli)

License:GNU General Public License v3.0


Languages

Language:Python 100.0%