Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Use AWS named profiles #1694

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions global_vars/noninteractive/amazon-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ aws_vpc_subnet_id_var: ""
aws_instance_name: streisand

# The AWS credentials to use.
aws_access_key: ""
aws_secret_key: ""
aws_profile: ""

# Definitions needed for Let's Encrypt HTTPS (or TLS) certificate setup.
#
Expand Down
8 changes: 2 additions & 6 deletions playbooks/amazon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,8 @@
default: "streisand"
private: no

- name: "aws_access_key"
prompt: "\n\nThe following information can be found in the IAM Management Console.\nhttps://console.aws.amazon.com/iam/home?#security_credential\n\nWhat is your AWS Access Key ID?\n"
private: no

- name: "aws_secret_key"
prompt: "\nWhat is your AWS Secret Access Key?\n"
- name: "aws_profile"
prompt: "\nWhat is your AWS named profile?\n"
private: no

- name: "confirmation"
Expand Down
24 changes: 8 additions & 16 deletions playbooks/roles/ec2-security-group/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
description: Security group for Streisand
region: "{{ aws_region }}"
vpc_id: "{{ aws_vpc_id | default(omit) }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"

- name: Pause for fifteen seconds to ensure the EC2 security group has been created
pause:
Expand All @@ -18,8 +17,7 @@
description: Security group for Streisand
region: "{{ aws_region }}"
vpc_id: "{{ aws_vpc_id | default(omit) }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
rules:
# Nginx
# ---
Expand Down Expand Up @@ -53,8 +51,7 @@
description: Security group for Streisand
region: "{{ aws_region }}"
vpc_id: "{{ aws_vpc_id | default(omit) }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
purge_rules: no
purge_rules_egress: no
rules:
Expand All @@ -80,8 +77,7 @@
description: Security group for Streisand
region: "{{ aws_region }}"
vpc_id: "{{ aws_vpc_id | default(omit) }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
purge_rules: no
purge_rules_egress: no
rules:
Expand All @@ -107,8 +103,7 @@
description: Security group for Streisand
region: "{{ aws_region }}"
vpc_id: "{{ aws_vpc_id | default(omit) }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
purge_rules: no
purge_rules_egress: no
rules:
Expand All @@ -128,8 +123,7 @@
description: Security group for Streisand
region: "{{ aws_region }}"
vpc_id: "{{ aws_vpc_id | default(omit) }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
purge_rules: no
purge_rules_egress: no
rules:
Expand All @@ -155,8 +149,7 @@
description: Security group for Streisand
region: "{{ aws_region }}"
vpc_id: "{{ aws_vpc_id | default(omit) }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
purge_rules: no
purge_rules_egress: no
rules:
Expand All @@ -182,8 +175,7 @@
description: Security group for Streisand
region: "{{ aws_region }}"
vpc_id: "{{ aws_vpc_id | default(omit) }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
purge_rules: no
purge_rules_egress: no
rules:
Expand Down
18 changes: 6 additions & 12 deletions playbooks/roles/genesis-amazon/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,21 @@
ec2_key:
name: streisand-ssh
state: absent
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
region: "{{ aws_region }}"
wait: yes

- name: Add the SSH key to Amazon under the name of 'streisand-ssh'
ec2_key:
name: streisand-ssh
key_material: "{{ ssh_key.stdout }}"
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
region: "{{ aws_region }}"
wait: yes

- name: Determine which AMI to use
ec2_ami_facts:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
owners: "{{ aws_ami_owner }}"
region: "{{ aws_region }}"
filters:
Expand All @@ -37,8 +34,7 @@

- name: Create the EC2 instance
ec2:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
instance_type: "{{ aws_instance_type }}"
image: "{{ ami.images|sort(reverse=True,attribute='name')|map(attribute='image_id')|first }}"
region: "{{ aws_region }}"
Expand All @@ -56,8 +52,7 @@
name: "autorecover-{{ aws_instance_name }}"
description: "This alarm will auto-recover the EC2 instance on host failure"
state: present
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
region: "{{ aws_region }}"
namespace: "AWS/EC2"
metric: StatusCheckFailed_System
Expand All @@ -81,8 +76,7 @@

- name: Allocate and associate Elastic IP
ec2_eip:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
profile: "{{ aws_profile }}"
region: "{{ aws_region }}"
device_id: "{{ streisand_server.instances[0].id }}"
in_vpc: "{{ aws_vpc_id is defined and aws_vpc_id != '' }}"
Expand Down