Skip to content

Commit

Permalink
Add support for Aarch64 instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Szpadel committed Jun 5, 2023
1 parent 72ec66e commit 04a5673
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 54 deletions.
4 changes: 2 additions & 2 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ aws_tags_kms_database:
# -------- AMI --------
# -----------------------

# AMI Name search pattern matching official CentOS 7 Marketplace AMI
# AMI Name search pattern matching official Rocky linux 9 Marketplace AMI
# Warning! You need to be subscribed to it first!
aws_ami_base_marketplace_name: "*b7ee8a69-ee97-4a49-9e68-afaee216db2e*"
aws_ami_base_marketplace_name: "Rocky-9-EC2-*"

# Whether to kill previously created builder or reuse it on next run
aws_ami_build_force_fresh_builder: no
Expand Down
45 changes: 27 additions & 18 deletions roles/cs.aws-ami-facts/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
ami_facts_instance: ""
ami_facts_architecture: "{{ ami_facts_architecture_map[ami_facts_instance.split('.')[0]] }}"

ami_facts_architecture_map:
t3: x86_64
m6a: x86_64
m6i: x86_64
m6g: arm64
t4g: arm64
c6g: arm64
c5: x86_64
c5a: x86_64
c6i: x86_64
c6a: x86_64
c7g: arm64
r6a: x86_64
r6i: x86_64
r6g: arm64
r5: x86_64
r5a: x86_64
r5b: x86_64

ami_facts_common_filters:
state: "available"
architecture: "x86_64"

# Deprecated - CentOS no longer updates the Marketplace AMIs
# ami_facts_clean_base_filters:
# name: "{{ aws_ami_base_marketplace_name }}"
# is-public: "true"
# owner-alias: "aws-marketplace"

# The image id of CentOS AWS images needs to be hardcoded and manually update now.
# Warning! The ids are different for each region, for no we use a hardcoded
# values for eu-central-1.
# Find the latest CentOS ami ids here: https://www.centos.org/download/aws-images/
ami_centos7_id:
# eu-central-1: ami-08b6d44b4f6f7b279 # original
eu-central-1: ami-06a38f9c5f75d09bd # rocky 9.0.20220706

ami_base_system_image_id: "{{ ami_centos7_id[aws_region | default('eu-central-1')] }}"
architecture: "{{ ami_facts_architecture }}"

ami_facts_clean_base_filters:
image-id: "{{ ami_base_system_image_id }}"
name: "{{ aws_ami_base_marketplace_name }}"
is-public: "true"
owner-alias: "aws-marketplace"

ami_facts_app_node_tags: "{{ aws_tags_base | combine(aws_tags_role_app) }}"

Expand All @@ -35,3 +43,4 @@ ami_facts_app_node_base_filters: >-
}}
ami_facts_app_node_filters: {}
aws_ami_clean_base_info: {}
40 changes: 19 additions & 21 deletions roles/cs.aws-ami-facts/tasks/find-clean-base-ami.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
- name: Find clean base AMIs
amazon.aws.ec2_ami_info:
region: "{{ aws_region }}"
filters: "{{ ami_facts_common_filters | combine(ami_facts_clean_base_filters) }}"
register: ami_clean_base_facts
- block:
- name: Find clean base AMIs
amazon.aws.ec2_ami_info:
region: "{{ aws_region }}"
filters: "{{ ami_facts_common_filters | combine(ami_facts_clean_base_filters) }}"
register: ami_clean_base_facts

- name: Fail if no clean base AMI is found
fail:
msg: Error! No clean base AMI found!
when: ami_clean_base_facts.images | length == 0
- name: Fail if no clean base AMI is found
fail:
msg: Error! No clean base AMI found!
when: ami_clean_base_facts.images | length == 0

- name: Set latest clean base AMI info fact
set_fact:
aws_ami_clean_base_info: "{{ ami_clean_base_facts.images | sort(attribute='creation_date') | last }}"
- name: Set latest clean base AMI info fact
set_fact:
aws_ami_clean_base_info_best: "{{ ami_clean_base_facts.images | sort(attribute='creation_date') | last }}"

- name: Set base clean AMI facts
set_fact:
aws_ami_clean_base_info: "{{ aws_ami_clean_base_info | combine( {ami_facts_architecture: aws_ami_clean_base_info_best} ) }}"
when: aws_ami_clean_base_info[ami_facts_architecture] is not defined

- name: Set base clean AMI facts
set_fact:
aws_ami_clean_base_id: "{{ aws_ami_clean_base_info.image_id }}"
aws_ami_clean_base_name: "{{ aws_ami_clean_base_info.name }}"
aws_ami_clean_base_location: "{{ aws_ami_clean_base_info.image_location }}"
aws_ami_root_device: "{{ aws_ami_clean_base_info.root_device_name }}"
aws_ami_clean_base_info: "{{ aws_ami_clean_base_info | combine( {ami_facts_instance: aws_ami_clean_base_info[ami_facts_architecture]} ) }}"

- name: Print information about base AMI found
debug:
msg: |
Clean base AMI information
==========================
{{ aws_ami_clean_base_name }} [{{ aws_ami_clean_base_id }}]
({{ aws_ami_clean_base_location }})
--- Details ---
{{ aws_ami_clean_base_info | to_nice_yaml }}
1 change: 0 additions & 1 deletion roles/cs.aws-autoscaling/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ dependencies:
- role: cs.ansible-plugins
- role: cs.aws-vpc-facts
- role: cs.aws-security-group-facts
- role: cs.aws-ami-facts
2 changes: 1 addition & 1 deletion roles/cs.aws-facts-all/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ dependencies:
- role: cs.aws-ami-facts
when: aws_facts_gather_ami
- role: cs.aws-autoscaling-facts
when: aws_facts_autoscaling
when: aws_facts_autoscaling
3 changes: 2 additions & 1 deletion roles/cs.aws-node-ami-builder/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dependencies:
- role: cs.aws-ami-facts
- role: cs.aws-ami-facts
ami_facts_instance: "{{ aws_app_builder_node_instance_type }}"
4 changes: 2 additions & 2 deletions roles/cs.aws-node-persistent/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aws_persistent_node_ami_id: "{{ aws_ami_clean_base_id }}"
aws_persistent_node_ami_id: "{{ aws_ami_clean_base_info[aws_persistent_node_instance_type].image_id }}"
aws_persistent_node_instance_type: t3a.micro
aws_persistent_node_ebs_volume_size: 10
aws_ansible_persistent_node_inventory_group: persistent
Expand All @@ -13,4 +13,4 @@ aws_persistent_node_security_groups:
aws_persistent_node_ebs_volume_type: "{{ aws_ec2_ebs_volume_type | default('gp3', true) }}"
aws_persistent_node_ebs_gp3_convert: "{{ aws_ec2_ebs_gp3_convert | default(false) }}"
aws_persistent_node_ebs_gp3_iops: "{{ aws_ec2_ebs_gp3_iops | default(3000, true) }}"
aws_persistent_node_ebs_gp3_throughput: "{{ aws_ec2_ebs_gp3_throughput | default(125, true) }}"
aws_persistent_node_ebs_gp3_throughput: "{{ aws_ec2_ebs_gp3_throughput | default(125, true) }}"
3 changes: 1 addition & 2 deletions roles/cs.aws-node-varnish/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
aws_varnish_node_ami_id: "{{ aws_ami_clean_base_id }}"
aws_varnish_node_ami_id: "{{ aws_ami_clean_base_info[aws_varnish_node_instance_type].image_id }}"
aws_varnish_node_instance_type: t3a.micro
aws_varnish_node_ebs_volume_size: 10
aws_ansible_varnish_node_inventory_group: varnish
Expand All @@ -14,4 +14,3 @@ aws_varnish_node_ebs_volume_type: "{{ aws_ec2_ebs_volume_type | default('gp3', t
aws_varnish_node_ebs_gp3_convert: "{{ aws_ec2_ebs_gp3_convert | default(false) }}"
aws_varnish_node_ebs_gp3_iops: "{{ aws_ec2_ebs_gp3_iops | default(3000, true) }}"
aws_varnish_node_ebs_gp3_throughput: "{{ aws_ec2_ebs_gp3_throughput | default(125, true) }}"

3 changes: 2 additions & 1 deletion roles/cs.varnish/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ varnish_workspace_client: 64k
varnish_workspace_thread: 4k

# As of varnish 6.0 the default is 48k and lower values cause segfault with our VCL
varnish_thread_pool_stack: 64k
# 128k is minimum for aarch64
varnish_thread_pool_stack: 128k

# Max. number of thread pools that should be at most the number of vCPUs
# See: https://varnish-cache.org/docs/6.0/reference/varnishd.html#thread-pool-max
Expand Down
7 changes: 5 additions & 2 deletions site.step-10-infrastructure-aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@
lb_http_port: "{{ mageops_varnish_port }}"
when: aws_elb_create
- role: cs.aws-ami-facts
ami_facts_instance: "{{ aws_varnish_node_instance_type }}"
- role: cs.aws-ami-facts
ami_facts_instance: "{{ aws_persistent_node_instance_type }}"
- role: cs.aws-node-facts
- role: cs.aws-node-varnish
aws_varnish_node_root_device: "{{ aws_ami_root_device }}"
aws_varnish_node_root_device: "{{ aws_ami_clean_base_info[aws_varnish_node_instance_type].root_device_name }}"
aws_varnish_node_vpc_subnet_id: "{{ aws_vpc_subnet_id }}"
aws_varnish_instance_id: "{{ aws_varnish_node_instance.instance_id | default(false) }}"
when: varnish_standalone
- role: cs.aws-node-persistent
aws_persistent_node_root_device: "{{ aws_ami_root_device }}"
aws_persistent_node_root_device: "{{ aws_ami_clean_base_info[aws_persistent_node_instance_type].root_device_name }}"
aws_persistent_node_vpc_subnet_id: "{{ aws_vpc_subnet_id }}"
aws_persistent_instance_id: "{{ aws_persistent_node_instance.instance_id | default(false) }}"
when: aws_persistent_node_create
Expand Down
6 changes: 3 additions & 3 deletions site.step-30-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
{{
aws_app_node_base_ami_id_forced | default(
aws_ami_force_clean_build | ternary(
aws_ami_clean_base_id,
aws_ami_app_node_id | default(aws_ami_clean_base_id, true)
aws_ami_clean_base_info[aws_app_builder_node_instance_type].image_id,
aws_ami_app_node_id | default(aws_ami_clean_base_info[aws_app_builder_node_instance_type].image_id, true)
),
true
)
Expand All @@ -30,7 +30,7 @@
builder_instance_ssh_key_name: "{{ aws_ec2_ssh_key_name }}"
builder_instance_iam_role: "{{ aws_iam_role_app_node }}"
builder_instance_user_data: "{{ aws_ec2_instance_user_data }}"
builder_instance_root_device: "{{ aws_ami_root_device }}"
builder_instance_root_device: "{{ aws_ami_clean_base_info[aws_app_builder_node_instance_type].root_device_name }}"
builder_instance_security_groups:
- "{{ aws_security_group_app_id }}"
- "{{ aws_security_group_ssh_id }}"
Expand Down
4 changes: 4 additions & 0 deletions site.step-60-autoscaling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
gather_facts: no
roles:
- role: cs.aws-ami-facts
ami_facts_instance: "{{ aws_app_node_instance_type }}"
delegate_to: localhost
tasks:
- block:
Expand Down Expand Up @@ -59,6 +60,9 @@
)
}}
roles:
- role: cs.aws-ami-facts
ami_facts_instance: "{{ aws_app_node_instance_type }}"
delegate_to: localhost
- role: cs.aws-autoscaling
autoscaling_assign_public_ip: yes
autoscaling_loadbalancers: "{{ aws_app_asg_load_balancers }}"
Expand Down

0 comments on commit 04a5673

Please sign in to comment.