From 9bc7042f76525d838027f356e1b1e1deff7103b4 Mon Sep 17 00:00:00 2001 From: "pascal.watteel@emc.com" Date: Sun, 12 Jan 2020 23:11:31 +0400 Subject: [PATCH 1/3] Updated the default to t3 instances, as they are now available in all zones and cheaper and more performance --- playbooks/roles/genesis-amazon/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/roles/genesis-amazon/defaults/main.yml b/playbooks/roles/genesis-amazon/defaults/main.yml index c19a5e225..65294ef1f 100644 --- a/playbooks/roles/genesis-amazon/defaults/main.yml +++ b/playbooks/roles/genesis-amazon/defaults/main.yml @@ -1,5 +1,5 @@ --- -aws_instance_type: "t2.micro" +aws_instance_type: "t3.micro" # Search AMIs owned by this owner. This is the Amazon owner ID. aws_ami_owner: "099720109477" # Find AMIs matching this name From 7f363541e0673c1cf6f0a25b501b69d6dee705d2 Mon Sep 17 00:00:00 2001 From: "pascal.watteel@emc.com" Date: Sun, 12 Jan 2020 23:12:09 +0400 Subject: [PATCH 2/3] make the menu a bit better visually --- playbooks/amazon.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/playbooks/amazon.yml b/playbooks/amazon.yml index 72eb6df3d..f5f9f8231 100644 --- a/playbooks/amazon.yml +++ b/playbooks/amazon.yml @@ -64,6 +64,7 @@ 16. us-east-2 US East (Ohio) 17. us-west-1 US West (N. California) 18. us-west-2 US West (Oregon) + Please choose the number of your region. Press enter for default (#16) region. default: "16" private: no From 42cf66f3cf696335b335638ed389ad11551ccc12 Mon Sep 17 00:00:00 2001 From: "pascal.watteel@emc.com" Date: Sun, 12 Jan 2020 23:13:22 +0400 Subject: [PATCH 3/3] migrate the old ec2 module to ec2_instances in preparation to support more boto3 based modules and newer ansible versions --- playbooks/roles/genesis-amazon/tasks/main.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/playbooks/roles/genesis-amazon/tasks/main.yml b/playbooks/roles/genesis-amazon/tasks/main.yml index 655e4bb75..c901950a5 100644 --- a/playbooks/roles/genesis-amazon/tasks/main.yml +++ b/playbooks/roles/genesis-amazon/tasks/main.yml @@ -36,17 +36,18 @@ register: ami - name: Create the EC2 instance - ec2: + ec2_instance: aws_access_key: "{{ aws_access_key }}" aws_secret_key: "{{ aws_secret_key }}" instance_type: "{{ aws_instance_type }}" - image: "{{ ami.images|sort(reverse=True,attribute='name')|map(attribute='image_id')|first }}" + image_id: "{{ ami.images|sort(reverse=True,attribute='name')|map(attribute='image_id')|first }}" region: "{{ aws_region }}" vpc_subnet_id: "{{ aws_vpc_subnet_id | default(omit) }}" - assign_public_ip: "{{ (aws_vpc_subnet_id is defined and aws_vpc_subnet_id != '') or omit }}" + network: + assign_public_ip: "{{ (aws_vpc_subnet_id is defined and aws_vpc_subnet_id != '') or omit }}" key_name: streisand-ssh - group: "{{ aws_security_group }}" - instance_tags: + security_group: "{{ aws_security_group }}" + tags: Name: "{{ aws_instance_name }}" wait: yes register: streisand_server @@ -67,14 +68,14 @@ period: 60 evaluation_periods: 2 dimensions: - InstanceId: "{{ streisand_server.instances[0].id }}" + InstanceId: "{{ streisand_server.instances[0].instance_id }}" alarm_actions: - "arn:aws:automate:{{ aws_region }}:ec2:recover" - when: aws_instance_type.startswith(("t2", "c3", "c4", "m3", "m4", "r3", "x1")) + when: aws_instance_type.startswith(("t2", "t3", "c3", "c4", "m3", "m4", "r3", "x1")) - name: Wait until the server has finished booting and OpenSSH is accepting connections wait_for: - host: "{{ streisand_server.instances[0].public_ip }}" + host: "{{ streisand_server.instances[0].public_ip_address }}" port: 22 search_regex: OpenSSH timeout: 600 @@ -84,7 +85,7 @@ aws_access_key: "{{ aws_access_key }}" aws_secret_key: "{{ aws_secret_key }}" region: "{{ aws_region }}" - device_id: "{{ streisand_server.instances[0].id }}" + device_id: "{{ streisand_server.instances[0].instance_id }}" in_vpc: "{{ aws_vpc_id is defined and aws_vpc_id != '' }}" register: instance_eip