Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction of Oracle Linux 7 instance to auto_satellite workshop. #2126

Open
wants to merge 10 commits into
base: devel
Choose a base branch
from
16 changes: 13 additions & 3 deletions provisioner/workshop_specific/auto_satellite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,25 @@
register: workshop_job_templates02
until: workshop_job_templates02.json.status == "successful"
delay: 20 # Every 20 seconds
retries: 15 # 5 minutes 5*60/20
retries: 30 # 10 minutes 10*60/20

- name: Run Z / SETUP / Workshop - CentOS7 deployment workflow template
awx.awx.workflow_launch:
workflow_template: "Z / SETUP / Workshop - CentOS7"
controller_username: admin
controller_password: "{{ admin_password }}"
controller_host: "https://{{ student }}.{{ ec2_name_prefix }}.{{ workshop_dns_zone }}"
timeout: 3900 # 63 minutes
when: centos7 is defined

- name: Run Z / SETUP / Workshop deployment workflow template
- name: Run Z / SETUP / Workshop - OL7 deployment workflow template
awx.awx.workflow_launch:
workflow_template: "Z / SETUP / Workshop deployment"
workflow_template: "Z / SETUP / Workshop - OL7"
controller_username: admin
controller_password: "{{ admin_password }}"
controller_host: "https://{{ student }}.{{ ec2_name_prefix }}.{{ workshop_dns_zone }}"
timeout: 3900 # 63 minutes
when: ol7 is defined

- name: Final workshop preparations - demo mode
when: provision_mode == "demo"
Expand Down
14 changes: 14 additions & 0 deletions roles/manage_ec2_instances/defaults/main/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,20 @@ ec2_info:
filter: 'CentOS*7*x86_64*'
username: centos
python_interpreter: '/usr/bin/python'
ol79:
owners: 131827586825
size:
- t3a.medium
- t2.medium
os_type: linux
disk_volume_type: gp3
disk_space: 10
disk_iops: 3000
disk_throughput: 125
architecture: x86_64
filter: 'OL7.9-x86_64-HVM-*'
username: ec2-user
python_interpreter: '/usr/bin/python'
f5node:
owners: 679593333241
size:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@
include_tasks: ami_find_centos_7.yml
when: (centos7 is defined) and (centos7 is not none)

- name: find ami for satellite
ec2_ami_info:
region: "{{ ec2_region }}"
owners: "{{ ec2_info['satellite'].owners }}"
filters:
name: "{{ ec2_info['satellite'].filter }}"
register: sat_amis
- name: find ami for oracle linux 7
include_tasks: ami_find_ol_7.yml
when: (ol7 is defined) and (ol7 is not none)

- name: save ami for satellite
set_fact:
sat_ami: >
{{ sat_amis.images | selectattr('name', 'defined') | sort(attribute='creation_date') | last }}
- name: Retry loop for find ami for satellite
include_tasks: ami_find_auto_satellite_loop.yml
...
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
- name: Find ami for satellite Task Group
block:
- name: Increment retry count
ansible.builtin.set_fact:
ami_find_subtasks_retry_count: "{{ 0 if ami_find_subtasks_retry_count is undefined else ami_find_subtasks_retry_count | int + 1 }}"
# - name: Resume or reset for failed tasks after each failed attempt
# ansible.builtin.include_tasks: some_other_task_resume_or_reset.yml
# when: ami_find_subtasks_retry_count | int != 0
- ansible.builtin.debug:
msg: "retry count: {{ ami_find_subtasks_retry_count }}"

- name: Include increasing delay for incremental retries
ansible.builtin.command: |
python3 -c 'import time;time.sleep({{ ami_find_subtasks_retry_count | int *60 }})'
delegate_to: localhost
connection: local

- name: Find ami for satellite
amazon.aws.ec2_ami_info:
region: "{{ ec2_region }}"
owners: "{{ ec2_info['satellite'].owners }}"
filters:
name: "{{ ec2_info['satellite'].filter }}"
register: sat_amis

- name: Save ami for satellite
ansible.builtin.set_fact:
sat_ami: >
{{ sat_amis.images | selectattr('name', 'defined') | sort(attribute='creation_date') | last }}

rescue:
- name: Maximum retries of grouped tasks reached
ansible.builtin.fail:
msg: Maximum retries of grouped tasks reached.
# initial try plus 4 retries = 5 total tries
when: ami_find_subtasks_retry_count | int == 4

- name: Instrument retry count
ansible.builtin.debug:
msg: "Task fail retry count: {{ ami_find_subtasks_retry_count }}"

- name: Loop back via include on this file
ansible.builtin.include_tasks: ami_find_auto_satellite_loop.yml
...
14 changes: 14 additions & 0 deletions roles/manage_ec2_instances/tasks/ami_find/ami_find_ol_7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: find ami for oracle linux 7 node
ec2_ami_info:
region: "{{ ec2_region }}"
owners: "{{ ec2_info[ol7].owners }}"
filters:
name: "{{ ec2_info[ol7].filter }}"
architecture: "{{ ec2_info[ol7].architecture }}"
register: amis

- name: save ami for oracle linux 7 node
set_fact:
node_ami_ol7: >
{{ amis.images | selectattr('name', 'defined') | sort(attribute='creation_date') | last }}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@
- name: provision aws centos 7 instances
include_tasks: instances_centos_7.yml
when: (centos7 is defined) and (centos7 is not none)

## oracle linux 7 nodes for potential convert2rhel scenarios
- name: provision aws oracle linux 7 instances
include_tasks: instances_ol_7.yml
when: (ol7 is defined) and (ol7 is not none)
...
12 changes: 12 additions & 0 deletions roles/manage_ec2_instances/tasks/instances/instances_ol_7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Oracle Linux 7 instance size list length
ansible.builtin.debug:
msg: "Oracle Linux 7 instance size list length: {{ ec2_info[ol7].size | length }}"

- name: Initialize/reset list count
ansible.builtin.set_fact:
list_count: "reset"

- name: Call Oracle Linux 7 retry tasks include
ansible.builtin.include_tasks: ol_7/ol_7_loop.yml
...
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
---
- name: Create EC2 instances for node4
amazon.aws.ec2_instance:
network:
assign_public_ip: true
key_name: "{{ ec2_name_prefix }}-key"
security_group: "{{ ec2_security_group }}"
instance_type: "{{ ec2_info[ol7].size[list_count|int] }}"
image_id: "{{ node_ami_ol7.image_id }}"
region: "{{ ec2_region }}"
exact_count: "{{ student_total|int }}"
state: running
filters:
instance-state-name: running
"tag:Workshop_node4": "{{ ec2_name_prefix }}-node4"
tags:
Workshop_node4: "{{ ec2_name_prefix }}-node4"
Workshop: "{{ ec2_name_prefix }}"
uuid: "{{ ec2_name_prefix }}"
guid: "{{ ec2_name_prefix }}"
Workshop_type: "{{ workshop_type }}"
AWS_USERNAME: "{{ aws_user }}"
owner: "{{ aws_user }}"
Info: "AWS_USERNAME that provisioned this-> {{ aws_user }}"
Linklight: "This was provisioned through the linklight provisioner"
Students: "{{ student_total|int }}"
short_name: "node4"
username: "{{ ec2_info[ol7].username }}"
ansible-workshops: "true"
wait: "{{ ec2_wait }}"
vpc_subnet_id: "{{ ec2_vpc_subnet_id }}"
volumes:
- device_name: /dev/sda1
ebs:
volume_type: "{{ ec2_info[ol7].disk_volume_type }}"
volume_size: "{{ ec2_info[ol7].disk_space }}"
iops: "{{ ec2_info[ol7].disk_iops }}"
throughput: "{{ ec2_info[ol7].disk_throughput }}"
delete_on_termination: true

- name: grab instance ids to tag node4
amazon.aws.ec2_instance_info:
region: "{{ ec2_region }}"
filters:
instance-state-name: running
"tag:Workshop_node4": "{{ ec2_name_prefix }}-node4"
register: node4_output

- name: Ensure tags are present for node4
amazon.aws.ec2_tag:
region: "{{ ec2_region }}"
resource: "{{ item.1.instance_id }}"
state: present
tags:
Name: "{{ ec2_name_prefix }}-student{{ item.0 + 1 }}-node4"
Index: "{{ item[0] }}"
Student: "student{{ item.0 + 1 }}"
launch_time: "{{ item.1.launch_time }}"
with_indexed_items:
- "{{ node4_output.instances }}"
when: node4_output.instances|length > 0

- name: Associate IAM instance profile with node4
amazon.aws.ec2_instance:
instance_ids: "{{ item.1.instance_id }}"
region: "{{ ec2_region }}"
instance_role: "VPCLockDown_{{ ec2_name_prefix }}_student{{ item.0 + 1 }}"
state: running
wait: true
with_indexed_items:
- "{{ node4_output.instances }}"
register: associate_iam_instance_profile
until: associate_iam_instance_profile is not failed
retries: 12
delay: 10
when:
- node4_output.instances|length > 0
- tower_node_aws_api_access|default(false)|bool

- name: Create EC2 instances for node5
amazon.aws.ec2_instance:
network:
assign_public_ip: true
key_name: "{{ ec2_name_prefix }}-key"
security_group: "{{ ec2_security_group }}"
instance_type: "{{ ec2_info[ol7].size[list_count|int] }}"
image_id: "{{ node_ami_ol7.image_id }}"
region: "{{ ec2_region }}"
exact_count: "{{ student_total|int }}"
state: running
filters:
instance-state-name: running
"tag:Workshop_node5": "{{ ec2_name_prefix }}-node5"
tags:
Workshop_node5: "{{ ec2_name_prefix }}-node5"
Workshop: "{{ ec2_name_prefix }}"
uuid: "{{ ec2_name_prefix }}"
guid: "{{ ec2_name_prefix }}"
Workshop_type: "{{ workshop_type }}"
AWS_USERNAME: "{{ aws_user }}"
owner: "{{ aws_user }}"
Info: "AWS_USERNAME that provisioned this-> {{ aws_user }}"
Linklight: "This was provisioned through the linklight provisioner"
Students: "{{ student_total|int }}"
short_name: "node5"
username: "{{ ec2_info[ol7].username }}"
ansible-workshops: "true"
wait: "{{ ec2_wait }}"
vpc_subnet_id: "{{ ec2_vpc_subnet_id }}"
volumes:
- device_name: /dev/sda1
ebs:
volume_type: "{{ ec2_info[ol7].disk_volume_type }}"
volume_size: "{{ ec2_info[ol7].disk_space }}"
iops: "{{ ec2_info[ol7].disk_iops }}"
throughput: "{{ ec2_info[ol7].disk_throughput }}"
delete_on_termination: true

- name: grab instance ids to tag them all
amazon.aws.ec2_instance_info:
region: "{{ ec2_region }}"
filters:
instance-state-name: running
"tag:Workshop_node5": "{{ ec2_name_prefix }}-node5"
register: node5_output

- name: Ensure tags are present for node5
amazon.aws.ec2_tag:
region: "{{ ec2_region }}"
resource: "{{ item.1.instance_id }}"
state: present
tags:
Name: "{{ ec2_name_prefix }}-student{{ item.0 + 1 }}-node5"
Index: "{{ item[0] }}"
Student: "student{{ item.0 + 1 }}"
launch_time: "{{ item.1.launch_time }}"
with_indexed_items:
- "{{ node5_output.instances }}"
when: node5_output.instances|length > 0

- name: Associate IAM instance profile with node5
amazon.aws.ec2_instance:
instance_ids: "{{ item.1.instance_id }}"
region: "{{ ec2_region }}"
instance_role: "VPCLockDown_{{ ec2_name_prefix }}_student{{ item.0 + 1 }}"
state: running
wait: true
with_indexed_items:
- "{{ node5_output.instances }}"
register: associate_iam_instance_profile
until: associate_iam_instance_profile is not failed
retries: 12
delay: 10
when:
- node5_output.instances|length > 0
- tower_node_aws_api_access|default(false)|bool

- name: Create EC2 instances for node6
amazon.aws.ec2_instance:
network:
assign_public_ip: true
key_name: "{{ ec2_name_prefix }}-key"
security_group: "{{ ec2_security_group }}"
instance_type: "{{ ec2_info[ol7].size[list_count|int] }}"
image_id: "{{ node_ami_ol7.image_id }}"
region: "{{ ec2_region }}"
exact_count: "{{ student_total|int }}"
state: running
filters:
instance-state-name: running
"tag:Workshop_node6": "{{ ec2_name_prefix }}-node6"
tags:
Workshop_node6: "{{ ec2_name_prefix }}-node6"
Workshop: "{{ ec2_name_prefix }}"
uuid: "{{ ec2_name_prefix }}"
guid: "{{ ec2_name_prefix }}"
Workshop_type: "{{ workshop_type }}"
AWS_USERNAME: "{{ aws_user }}"
owner: "{{ aws_user }}"
Info: "AWS_USERNAME that provisioned this-> {{ aws_user }}"
Linklight: "This was provisioned through the linklight provisioner"
Students: "{{ student_total|int }}"
short_name: "node6"
username: "{{ ec2_info[ol7].username }}"
ansible-workshops: "true"
wait: "{{ ec2_wait }}"
vpc_subnet_id: "{{ ec2_vpc_subnet_id }}"
volumes:
- device_name: /dev/sda1
ebs:
volume_type: "{{ ec2_info[ol7].disk_volume_type }}"
volume_size: "{{ ec2_info[ol7].disk_space }}"
iops: "{{ ec2_info[ol7].disk_iops }}"
throughput: "{{ ec2_info[ol7].disk_throughput }}"
delete_on_termination: true

- name: grab instance ids to tag node6
amazon.aws.ec2_instance_info:
region: "{{ ec2_region }}"
filters:
instance-state-name: running
"tag:Workshop_node6": "{{ ec2_name_prefix }}-node6"
register: node6_output

- name: Ensure tags are present for node6
amazon.aws.ec2_tag:
region: "{{ ec2_region }}"
resource: "{{ item.1.instance_id }}"
state: present
tags:
Name: "{{ ec2_name_prefix }}-student{{ item.0 + 1 }}-node6"
Index: "{{ item[0] }}"
Student: "student{{ item.0 + 1 }}"
launch_time: "{{ item.1.launch_time }}"
with_indexed_items:
- "{{ node6_output.instances }}"
when: node6_output.instances|length > 0

- name: Associate IAM instance profile with node6
amazon.aws.ec2_instance:
instance_ids: "{{ item.1.instance_id }}"
region: "{{ ec2_region }}"
instance_role: "VPCLockDown_{{ ec2_name_prefix }}_student{{ item.0 + 1 }}"
state: running
wait: true
with_indexed_items:
- "{{ node6_output.instances }}"
register: associate_iam_instance_profile
until: associate_iam_instance_profile is not failed
retries: 12
delay: 10
when:
- node6_output.instances|length > 0
- tower_node_aws_api_access|default(false)|bool
Loading