partial cherry pick from 973c02f7b1
This commit is contained in:
parent
60433fb935
commit
366aa71d9a
|
@ -6,3 +6,4 @@ deprecation_warnings = False
|
||||||
host_key_checking = false
|
host_key_checking = false
|
||||||
log_path = log.txt
|
log_path = log.txt
|
||||||
hash_behaviour = merge
|
hash_behaviour = merge
|
||||||
|
display_skipped_hosts = false
|
|
@ -1,8 +1,7 @@
|
||||||
- name: Destroy infrastructure
|
- name: Destroy infrastructure
|
||||||
hosts: all
|
hosts: all
|
||||||
serial: 1
|
|
||||||
roles:
|
roles:
|
||||||
- { role: destroy, when: "confirmation|bool == True" }
|
- { role: destroy, when: "confirmation|bool == True and inventory_hostname == groups[group_names[0]][0]" }
|
||||||
vars_prompt:
|
vars_prompt:
|
||||||
- name: "confirmation"
|
- name: "confirmation"
|
||||||
prompt: "Are you sure you want to destroy all the infra?"
|
prompt: "Are you sure you want to destroy all the infra?"
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
# Internal DNS Zone
|
# Internal DNS Zone
|
||||||
resource "aws_route53_zone" "main" {
|
resource "aws_route53_zone" "main" {
|
||||||
name = "${var.prefix}.${var.dns_zone_name}"
|
name = "${var.prefix}.${var.dns_zone_name}"
|
||||||
|
vpc {
|
||||||
vpc_id = "${aws_vpc.vpc.id}"
|
vpc_id = "${aws_vpc.vpc.id}"
|
||||||
|
}
|
||||||
|
|
||||||
tags {
|
tags {
|
||||||
prefix = "${var.prefix}"
|
prefix = "${var.prefix}"
|
||||||
|
|
|
@ -147,9 +147,10 @@ EOF
|
||||||
|
|
||||||
log "Installing Erlang.."
|
log "Installing Erlang.."
|
||||||
|
|
||||||
wget https://packages.erlang-solutions.com/erlang/rpm/centos/7/x86_64/esl-erlang_21.1-1~centos~7_amd64.rpm
|
erlang_version="esl-erlang_22.0-1~centos~7_amd64.rpm"
|
||||||
|
wget https://packages.erlang-solutions.com/erlang/rpm/centos/7/x86_64/${erlang_version}
|
||||||
yum localinstall -y wxGTK-devel unixODBC-devel >"$LOG"
|
yum localinstall -y wxGTK-devel unixODBC-devel >"$LOG"
|
||||||
yum localinstall -y esl-erlang_21.1-1~centos~7_amd64.rpm >"$LOG"
|
yum localinstall -y ${erlang_version} >"$LOG"
|
||||||
|
|
||||||
log "Fetching configuration from Parameter Store..."
|
log "Fetching configuration from Parameter Store..."
|
||||||
fetch_ssm_with_token
|
fetch_ssm_with_token
|
||||||
|
|
|
@ -16,7 +16,7 @@ resource "aws_subnet" "default" {
|
||||||
## ALB subnet
|
## ALB subnet
|
||||||
resource "aws_subnet" "alb" {
|
resource "aws_subnet" "alb" {
|
||||||
vpc_id = "${aws_vpc.vpc.id}"
|
vpc_id = "${aws_vpc.vpc.id}"
|
||||||
cidr_block = "${var.public_subnet_cidr}"
|
#cidr_block = var.public_subnet_cidr
|
||||||
cidr_block = "${cidrsubnet(var.db_subnet_cidr, 5, 1)}"
|
cidr_block = "${cidrsubnet(var.db_subnet_cidr, 5, 1)}"
|
||||||
availability_zone = "${data.aws_availability_zones.available.names[1]}"
|
availability_zone = "${data.aws_availability_zones.available.names[1]}"
|
||||||
map_public_ip_on_launch = true
|
map_public_ip_on_launch = true
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
variable "aws_profile" {
|
||||||
|
default = "null"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "aws_region" {
|
||||||
|
default = "null"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "aws_access_key" {
|
||||||
|
default = "null"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "aws_secret_key" {
|
||||||
|
default = "null"
|
||||||
|
}
|
||||||
|
|
||||||
variable "prefix" {}
|
variable "prefix" {}
|
||||||
variable "key_name" {}
|
variable "key_name" {}
|
||||||
variable "vpc_cidr" {}
|
variable "vpc_cidr" {}
|
||||||
|
|
|
@ -64,9 +64,9 @@
|
||||||
args:
|
args:
|
||||||
chdir: "/tmp/files-{{ group_names[0] }}"
|
chdir: "/tmp/files-{{ group_names[0] }}"
|
||||||
with_items:
|
with_items:
|
||||||
- "init{{ ' -backend-config=backend.tfvars' if backend|bool == true else '' }}"
|
- "init{{ ' -backend-config=backend.tfvars' if backend|bool else '' }}"
|
||||||
- plan -out terraform.tfplan
|
- plan -out terraform.tfplan
|
||||||
- show terraform.tfplan -no-color
|
- show -no-color terraform.tfplan
|
||||||
|
|
||||||
- name: Show Terraform plan
|
- name: Show Terraform plan
|
||||||
debug:
|
debug:
|
||||||
|
@ -92,13 +92,10 @@
|
||||||
args:
|
args:
|
||||||
chdir: "/tmp/files-{{ group_names[0] }}"
|
chdir: "/tmp/files-{{ group_names[0] }}"
|
||||||
when: hostvars[groups['all'][0]].user_answer.user_input | bool
|
when: hostvars[groups['all'][0]].user_answer.user_input | bool
|
||||||
ignore_errors: True
|
retries: 1
|
||||||
|
delay: 3
|
||||||
- name: Ensure Terraform resources has been provisioned
|
register: result
|
||||||
shell: "echo yes | {{ terraform_location }} apply"
|
until: result.rc == 0
|
||||||
args:
|
|
||||||
chdir: "/tmp/files-{{ group_names[0] }}"
|
|
||||||
when: hostvars[groups['all'][0]].user_answer.user_input | bool
|
|
||||||
|
|
||||||
- name: Terraform output info into variable
|
- name: Terraform output info into variable
|
||||||
shell: "{{ terraform_location }} output -json"
|
shell: "{{ terraform_location }} output -json"
|
||||||
|
@ -109,7 +106,7 @@
|
||||||
|
|
||||||
- name: Output info from Terraform
|
- name: Output info from Terraform
|
||||||
debug:
|
debug:
|
||||||
var: output.stdout_lines
|
var: (output.stdout|from_json).instructions.value
|
||||||
when: hostvars[groups['all'][0]].user_answer.user_input | bool
|
when: hostvars[groups['all'][0]].user_answer.user_input | bool
|
||||||
|
|
||||||
- name: Ansible delete file glob
|
- name: Ansible delete file glob
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
terraform {
|
terraform {
|
||||||
backend "s3" {
|
backend "s3" {
|
||||||
{% if aws_access_key is undefined %}
|
{% if aws_access_key is undefined or aws_access_key == '' %}
|
||||||
profile = "{{ aws_profile|default("default") }}"
|
profile = "{{ aws_profile|default("default") }}"
|
||||||
{% else %}
|
{% else %}
|
||||||
access_key = "{{ aws_access_key }}"
|
access_key = "{{ aws_access_key }}"
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
{% if aws_access_key is undefined or aws_access_key == '' %}
|
||||||
|
aws_profile = "{{ aws_profile|default('default') }}"
|
||||||
|
{% else %}
|
||||||
|
aws_access_key = "{{ aws_access_key | default('null') }}"
|
||||||
|
aws_secret_key = "{{ aws_secret_key | default('null') }}"
|
||||||
|
{% endif %}
|
||||||
|
aws_region = "{{ aws_region | default('us-east-1') }}"
|
||||||
|
|
||||||
prefix = "{{ group_names[0] }}"
|
prefix = "{{ group_names[0] }}"
|
||||||
key_name = "{{ ec2_ssh_key_name }}"
|
key_name = "{{ ec2_ssh_key_name }}"
|
||||||
key_content = "{{ ec2_ssh_key_content }}"
|
key_content = "{{ ec2_ssh_key_content }}"
|
||||||
|
|
Loading…
Reference in New Issue