Skip to content

Commit

Permalink
AMI support Amazon Linux 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
phuhung273 committed Dec 16, 2024
1 parent cf2dbed commit 4491b30
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 19 deletions.
6 changes: 4 additions & 2 deletions images/capi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ NODE_OVA_VSPHERE_BUILD_NAMES := $(addprefix node-ova-vsphere-,$(PLATFORMS_AND_V
NODE_OVA_VSPHERE_BASE_BUILD_NAMES := $(addprefix node-ova-vsphere-base-,$(PLATFORMS_AND_VERSIONS))
NODE_OVA_VSPHERE_CLONE_BUILD_NAMES := $(addprefix node-ova-vsphere-clone-,$(PLATFORMS_AND_VERSIONS))

AMI_BUILD_NAMES ?= ami-centos-7 ami-ubuntu-2004 ami-ubuntu-2204 ami-ubuntu-2404 ami-amazon-2 ami-flatcar ami-windows-2019 ami-rockylinux-8 ami-rhel-8
AMI_BUILD_NAMES ?= ami-centos-7 ami-ubuntu-2004 ami-ubuntu-2204 ami-ubuntu-2404 ami-amazon-2 ami-amazon-2023 ami-flatcar ami-windows-2019 ami-rockylinux-8 ami-rhel-8
GCE_BUILD_NAMES ?= gce-ubuntu-2004 gce-ubuntu-2204 gce-ubuntu-2404 gce-rhel-8

# Make needs these lists to be space delimited, no quotes
Expand Down Expand Up @@ -646,6 +646,7 @@ $(RAW_CLEAN_TARGETS):
## --------------------------------------
##@ Builds
build-ami-amazon-2: ## Builds Amazon-2 Linux AMI
build-ami-amazon-2023: ## Builds Amazon-2023 Linux AMI
build-ami-centos-7: ## Builds CentOS 7 AMI
build-ami-ubuntu-2004: ## Builds Ubuntu 20.04 AMI
build-ami-ubuntu-2204: ## Builds Ubuntu 22.04 AMI
Expand Down Expand Up @@ -877,7 +878,8 @@ build-vultr-ubuntu-2204: ## Builds Ubuntu 22.04 Vultr Snapshot
## --------------------------------------
##@ Validate packer config
validate-ami-amazon-2: ## Validates Amazon-2 Linux AMI Packer config
validate-ami-centos-7: ## Validates CentOS 7 AMI Packer config
validate-ami-amazon-2023: ## Validates Amazon-2023 Linux AMI Packer config
validate-ami-centos-7: ## Validates CentOS 7 AMI Packer c`onfig
validate-ami-rockylinux-8: ## Validates RockyLinux 8 AMI Packer config
validate-ami-rhel-8: ## Validates RHEL-8 AMI Packer config
validate-ami-flatcar: ## Validates Flatcar AMI Packer config
Expand Down
18 changes: 16 additions & 2 deletions images/capi/ansible/roles/node/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,45 @@ common_rpms:
- ca-certificates
- conntrack-tools
- chrony
- curl
- jq
- python3-pip
- socat
- sysstat
- yum-utils

# Used for AmazonLinux-2 distributions
al2_rpms:
- curl
- yum-utils
- ebtables
- python-netifaces
- python-requests
- amazon-ssm-agent
- awscli

# Used for AmazonLinux-2023 distributions
al2023_rpms:
- unzip
- amazon-ssm-agent
- awscli-2

# Used for Azure Linux distributions
azurelinux_rpms:
- curl
- yum-utils
- lsof

# Used for RedHat based distributions == 7 (ex. RHEL-7, CentOS-7 etc.)
rh7_rpms:
- curl
- yum-utils
- ebtables
- python-netifaces
- python-requests

# Used for RedHat based distributions =! 7 (ex. RHEL-8, RockyLinux-8, RockyLinux-9 etc.)
rh8_rpms:
- curl
- yum-utils
- nftables
- python3-netifaces
- python3-requests
Expand Down
8 changes: 7 additions & 1 deletion images/capi/ansible/roles/node/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ dependencies:
vars:
rpms: "{{ common_rpms + al2_rpms + lookup('vars', 'common_' + build_target + '_rpms') }}"
debs: "{{ common_debs }}"
when: ansible_distribution == "Amazon"
when: ansible_distribution == "Amazon" and ansible_distribution_version == "2"

- role: setup
vars:
rpms: "{{ common_rpms + al2023_rpms + lookup('vars', 'common_' + build_target + '_rpms') }}"
debs: "{{ common_debs }}"
when: ansible_distribution == "Amazon" and ansible_distribution_version == "2023"

- role: setup
vars:
Expand Down
2 changes: 1 addition & 1 deletion images/capi/ansible/roles/node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- ansible.builtin.import_tasks: photon.yml
when: ansible_os_family == "VMware Photon OS"

- ansible.builtin.import_tasks: amazonLinux2.yml
- ansible.builtin.import_tasks: amazonLinux.yml
when: ansible_distribution == "Amazon"

# This is required until https://github.com/ansible/ansible/issues/77537 is fixed and used.
Expand Down
9 changes: 0 additions & 9 deletions images/capi/ansible/roles/providers/tasks/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@
- ansible_os_family == "RedHat"
- ansible_distribution != "Amazon"

- name: Install aws agents RPM
ansible.builtin.package:
name: "{{ item }}"
state: present
with_items:
- amazon-ssm-agent
- awscli
when: ansible_distribution == "Amazon"

- name: Ensure ssm agent is running RPM
ansible.builtin.service:
name: amazon-ssm-agent
Expand Down
8 changes: 8 additions & 0 deletions images/capi/ansible/roles/sysprep/tasks/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
path: /etc/yum.conf
regexp: ^exclude=
line: exclude={{ package_list }}
when: ansible_distribution != "Amazon" or ansible_distribution_version != "2023"

- name: Exclude packages from upgrade
ansible.builtin.lineinfile:
path: /etc/dnf/dnf.conf
regexp: ^excludepkgs=
line: excludepkgs={{ package_list }}
when: ansible_distribution == "Amazon" and ansible_distribution_version == "2023"

- ansible.builtin.import_tasks: rpm_repos.yml

Expand Down
1 change: 1 addition & 0 deletions images/capi/packer/ami/amazon-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"distribution": "Amazon Linux",
"distribution_release": "Amazon Linux 2",
"distribution_version": "2",
"distro_version": "2",
"root_device_name": "/dev/xvda",
"source_ami": "",
"ssh_username": "ec2-user"
Expand Down
14 changes: 14 additions & 0 deletions images/capi/packer/ami/amazon-2023.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"ami_filter_name": "al2023-ami-minimal-2023.*-kernel-6.1*",
"ami_filter_owners": "amazon",
"build_name": "amazon-2023",
"distribution": "Amazon Linux",
"distribution_release": "Amazon Linux 2023",
"distribution_version": "2023",
"distro_version": "2023",
"epel_rpm_gpg_key": "",
"redhat_epel_rpm": "",
"root_device_name": "/dev/xvda",
"source_ami": "",
"ssh_username": "ec2-user"
}
22 changes: 18 additions & 4 deletions images/capi/packer/goss/goss-vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,33 @@ common_rpms: &common_rpms
cloud-utils-growpart:
conntrack-tools:
chrony:
curl:
jq:
python3-pip:
socat:
sysstat:
yum-utils:

al2_rpms: &al2_rpms
curl:
yum-utils:
ebtables:
python-netifaces:
python-requests:
awscli:

al2023_rpms: &al2023_rpms
unzip:
awscli-2:

rh7_rpms: &rh7_rpms
curl:
yum-utils:
ebtables:
python-netifaces:
python-requests:

rh8_rpms: &rh8_rpms
curl:
yum-utils:
nftables:
python3-netifaces:
python3-requests:
Expand Down Expand Up @@ -136,9 +145,14 @@ amazon linux:
enabled: true
running: true
package:
awscli:
amazon-ssm-agent:
<<: *al2_rpms
os_version:
- distro_version: "2"
package:
<<: *al2_rpms
- distro_version: "2023"
package:
<<: *al2023_rpms
centos:
common-package: *common_rpms
amazon:
Expand Down

0 comments on commit 4491b30

Please sign in to comment.