Skip to content

Instantly share code, notes, and snippets.

View nleiva's full-sized avatar
☠️
Working from somewhere

Nicolas Leiva nleiva

☠️
Working from somewhere
View GitHub Profile
- name: Provision EC2 instance
community.aws.ec2_instance:
name: "{{ ec2_name_tag }}"
region: "{{ ec2_region }}"
instance_type: "{{ ec2_instance_type }}"
image_id: "{{ ec2_ami_id }}"
key_name: "{{ ec2_resource_prefix }}-key"
vpc_subnet_id: "{{ create_subnet.subnet.id }}"
network:
assign_public_ip: true
- name: Create Route Table
community.aws.ec2_vpc_route_table:
region: "{{ ec2_region }}"
vpc_id: "{{ create_vpc.vpc.id }}"
subnets:
- "{{ create_subnet.subnet.id }}"
routes:
- dest: 0.0.0.0/0
gateway_id: "{{ igw.gateway_id }}"
tags:
- name: Create Internet Gateway
community.aws.ec2_vpc_igw:
region: "{{ ec2_region }}"
vpc_id: "{{ create_vpc.vpc.id }}"
tags:
Environment: "{{ ec2_environment }}"
register: igw
- name: Create Subnet
amazon.aws.ec2_vpc_subnet:
region: "{{ ec2_region }}"
vpc_id: "{{ create_vpc.vpc.id }}"
cidr: "{{ ec2_subnet }}"
tags:
Environment: "{{ ec2_environment }}"
register: create_subnet
- name: Create EC2 Security Group
amazon.aws.ec2_group:
name: "{{ ec2_resource_prefix }}-SG"
description: Security Group for Testing VM
region: "{{ ec2_region }}"
vpc_id: "{{ create_vpc.vpc.id }}"
tags:
Environment: "{{ ec2_environment }}"
rules:
- proto: tcp
- name: Create AWS VPC
amazon.aws.ec2_vpc_net:
name: "{{ ec2_resource_prefix }}-vpc"
cidr_block:
- "{{ ec2_cidr_block }}"
region: "{{ ec2_region }}"
tags:
Environment: "{{ ec2_environment }}"
register: create_vpc
- name: Create SSH Key Pair for instance
amazon.aws.ec2_key:
name: "{{ ec2_resource_prefix }}-key"
region: "{{ ec2_region }}"
register: create_key
- name: Save Private Key
ansible.builtin.copy:
content: "{{ create_key.key.private_key }}"
dest: "{{ playbook_dir }}/{{ ec2_resource_prefix }}-private.pem"
@nleiva
nleiva / tree.php
Last active September 18, 2020 02:11
⇨ tree roles/go_role/
roles/go_role/
├── library
│ ├── calendar_darwin
│ ├── calendar_linux
│ ├── calendar_windows
│ └── go_run
└── tasks
├── Darwin.yml
├── Go.yml
@nleiva
nleiva / go.sh
Created September 14, 2020 21:37
#!/bin/bash
source $1
# Fail if time is not set or add a sane default
if [ -z "$time" ]; then
time=$(date --iso-8601=seconds)
fi
printf '{"Name": "%s", "Time": "%s"}' "$name" "$time" > $file
// Response are the values returned from the module
type Response struct {
Msg string `json:"msg"`
Busy bool `json:"busy"`
Changed bool `json:"changed"`
Failed bool `json:"failed"`
}
func returnResponse(r Response) {
...