https://github.com/mtulio/ansible-role-cloud-compute
Ansible Role to manager Compute Resources
https://github.com/mtulio/ansible-role-cloud-compute
Last synced: 3 months ago
JSON representation
Ansible Role to manager Compute Resources
- Host: GitHub
- URL: https://github.com/mtulio/ansible-role-cloud-compute
- Owner: mtulio
- License: apache-2.0
- Created: 2022-01-15T14:11:36.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-04T14:31:11.000Z (almost 3 years ago)
- Last Synced: 2025-11-16T09:20:35.872Z (7 months ago)
- Language: Jinja
- Size: 47.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ansible-role-cloud-compute
[](https://github.com/mtulio/ansible-role-cloud-compute/actions/workflows/release.yml)
[](https://github.com/mtulio/ansible-role-cloud-compute/actions/workflows/ci.yml)
[](https://galaxy.ansible.com/mtulio/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
```bash
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:
```yaml
- 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:
```bash
ansible-playbook create.yaml -e provider=aws -e name=my-machine
```
### Provider: Digital Ocean
- Install Dependencies
```bash
ansible-galaxy collection install community.digitalocean
```
- Export variables
```bash
export SSH_KEY=$(cat ~/.ssh/id_rsa.pub)
```
- Create the Playbook
```yaml
- hosts: localhost
vars:
compute_resources:
# Module 'machine' options:
- provider: do
type: machine
name: "{{ name }}"
state: present
user_data: ""
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:
```bash
ansible-playbook create.yaml -e provider=do -e name=my-machine
```
License
-------
Apache v2
Author Information
------------------
[Marco Tulio R Braga](https://github.com/mtulio)