cloud_compute

ansible-role-cloud-compute

Ansible Role to manage cloud compute resources.

Requirements

  • ansible >= 2.10

Provider=AWS:

  • boto3

Role Variables

compute_resources: List of compute resources to be created. Only machine is supported.

Usage Examples

Provider: AWS

  • Install Dependencies
pip3 install boto3
ansible-galaxy install collection community.aws
ansible-galaxy install collection amazon.aws
  • Create the playbook file create.yaml to create EC2 Instance on AWS:
- hosts: localhost
  vars:
    compute_resources:
      - provider: "aws"
        type: machine
        user_data: ""
        vpc_subnet_id: "subnet-1234567"
        instance_type: m5.xlarge
        image_id: ami-123456789
        filters:
          tag:Name: "{{ name }}"
          instance-state-name: running
        tags:
          Name: "{{ name }}"

  roles:
    - role: mtulio.cloud-compute
  • Run the Playbook:
ansible-playbook create.yaml -e provider=aws -e name=my-machine

Provider: Digital Ocean

  • Install Dependencies
ansible-galaxy collection install community.digitalocean
  • Export variables
export SSH_KEY=$(cat ~/.ssh/id_rsa.pub)
  • Create the Playbook
- hosts: localhost
  vars:
    compute_resources:
      # Module 'machine' options:
      - provider: do
        type: machine
        name: "{{ name }}"
        state: present
        user_data: "<CHANGE_ME_USERDATA>"
        vpc_name: "my-vpc-name"
        wait: "yes"
        wait_timeout: 500
        image_name: "fedora-coreos-34.20210626.3.1-digitalocean.x86_64.qcow2.gz"
        private_networking: yes
        project_name: "my-project"
        region: "NYC3"
        size: "s-4vcpu-8gb"
        ssh_key:
          name: "my-key"
          pub_key: "{{ lookup('ansible.builtin.env', 'SSH_KEY') }}"

  roles:
    - role: mtulio.cloud-compute
  • Run the Playbook:
ansible-playbook create.yaml -e provider=do -e name=my-machine

License

Apache v2

Author Information

Marco Tulio R Braga

About

Manage Cloud Compute resources

Install
ansible-galaxy install mtulio/ansible-role-cloud-compute
GitHub repository
License
apache-2.0
Downloads
21
Owner