Skip to content

Commit

Permalink
syncing changes for mike
Browse files Browse the repository at this point in the history
  • Loading branch information
IPvSean committed Oct 26, 2023
1 parent f7327d2 commit 99645b5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 27 deletions.
29 changes: 15 additions & 14 deletions roles/manage_ec2_instances/defaults/main/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ rtr4_type: "arista"
rhel: "rhel8"
# additional info needed by AWS ec2 modules
ec2_info:
control_type_pre_build:
owners: 962147768365
architecture: x86_64
filter: 'automation_controller*'
# username: ec2-user
# size:
# - m5a.xlarge
# - m4.xlarge
# os_type: linux
# disk_volume_type: gp3
# disk_space: 40
# disk_iops: 3000
# disk_throughput: 125
private_automation_hub:
owners: 309956199498
size: m4.xlarge
Expand Down Expand Up @@ -331,20 +344,8 @@ debug_teardown: false
# Issue #1594
ansible_async_dir: "/tmp/.ansible_async"

control_type_pre_build:
owners: 962147768365
architecture: x86_64
filter: 'automation_controller*'
username: ec2-user
# size:
# - m5a.xlarge
# - m4.xlarge
# os_type: linux
# disk_volume_type: gp3
# disk_space: 40
# disk_iops: 3000
# disk_throughput: 125



# pre_build_controller_ami:
# ap-northeast-1: ami-06ad1ea5c12a0d0f7
# ap-southeast-1: ami-08e2518f0780bc79b
Expand Down
8 changes: 7 additions & 1 deletion roles/manage_ec2_instances/tasks/check_prebuild.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
---
- name: make sure we have access to pre_build AMI
block:
- name: print AMI to terminal window
debug:
var: ansible_control_node_ami

- name: check if we have access to AMI
amazon.aws.ec2_ami_info:
region: "{{ ec2_region }}"
image_ids: "{{ pre_build_controller_ami[ec2_region] }}"
image_ids:
- "{{ ansible_control_node_ami.image_id }}"

rescue:
- name: AWS AMI Access is not available
fail:
Expand Down
7 changes: 6 additions & 1 deletion roles/manage_ec2_instances/tasks/check_prebuild_hub.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
---
- name: make sure we have access to pre_build hub AMI
block:
- name: print AMI to terminal window
debug:
var: ansible_hub_node_ami

- name: check if we have access to AMI
amazon.aws.ec2_ami_info:
region: "{{ ec2_region }}"
image_ids: "{{ pre_build_hub_ami[ec2_region] }}"
image_ids:
- "{{ ansible_hub_node_ami.image_id }}"
rescue:
- name: AWS AMI Access is not available
fail:
Expand Down
7 changes: 0 additions & 7 deletions roles/manage_ec2_instances/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
- include_tasks: teardown.yml
when: teardown|bool

- name: check if we have access to pre_build AMI images
include_tasks: check_prebuild.yml

- name: check if we have access to pre_build hub AMI images
include_tasks: check_prebuild_hub.yml
when: automation_hub|bool and pre_build|bool

- name: provision aws resources and instances
include_tasks: provision.yml
tags: provisioned
Expand Down
15 changes: 11 additions & 4 deletions roles/manage_ec2_instances/tasks/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@
- name: save ami for ansible control node pre_build
when: pre_build|bool
block:
- name: find ami for ansible control node
- name: find ami for ansible control node with pre_build image
amazon.aws.ec2_ami_info:
region: "{{ ec2_region }}"
owners: "{{ ec2_info[control_type_pre_build].owners }}"
owners: "{{ ec2_info.control_type_pre_build.owners }}"
filters:
name: "{{ ec2_info[control_type_pre_build].filter }}"
architecture: "{{ ec2_info[control_type_pre_build].architecture }}"
name: "{{ ec2_info.control_type_pre_build.filter }}"
architecture: "{{ ec2_info.control_type_pre_build.architecture }}"
register: amis

- name: save ami for ansible control node
set_fact:
ansible_control_node_ami: >
{{ amis.images | selectattr('name', 'defined') | sort(attribute='name') | last }}
- name: check if we have access to pre_build AMI images
include_tasks: check_prebuild.yml

- name: enforce major and minor version are at least RHEL 8.4
assert:
that:
Expand Down Expand Up @@ -88,6 +91,10 @@
- name: find correct AMI
include_tasks: 'ami_find/ami_find_{{ workshop_type }}.yml'

- name: check if we have access to pre_build hub AMI images
include_tasks: check_prebuild_hub.yml
when: automation_hub|bool and pre_build|bool

## Instance creation
- name: provision workshop instances
include_tasks: 'instances/instances_{{ workshop_type }}.yml'
Expand Down

0 comments on commit 99645b5

Please sign in to comment.