This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Create Internet Gateway | |
community.aws.ec2_vpc_igw: | |
region: "{{ ec2_region }}" | |
vpc_id: "{{ create_vpc.vpc.id }}" | |
tags: | |
Environment: "{{ ec2_environment }}" | |
register: igw |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⇨ tree roles/go_role/ | |
roles/go_role/ | |
├── library | |
│ ├── calendar_darwin | |
│ ├── calendar_linux | |
│ ├── calendar_windows | |
│ └── go_run | |
└── tasks | |
├── Darwin.yml | |
├── Go.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { | |
... |