|
54 | 54 | cidr_ip: 0.0.0.0/0 |
55 | 55 | register: sg |
56 | 56 |
|
57 | | - - name: Lookup Fedora Cloud Base AMIs (x86_64, HVM, EBS) from Fedora Project |
| 57 | + # Replace the Fedora lookup with a RHEL 10 Marketplace lookup |
| 58 | + - name: Lookup latest RHEL 10 HVM SSD AMI (x86_64) from Red Hat / AWS Marketplace |
58 | 59 | amazon.aws.ec2_ami_info: |
59 | 60 | region: "{{ aws_region }}" |
60 | 61 | owners: |
61 | | - - "125523088429" # Fedora Project |
| 62 | + - "309956199498" # Red Hat, Inc. |
| 63 | + - "aws-marketplace" # Include Marketplace-owned images (requires subscription) |
62 | 64 | filters: |
63 | | - name: "Fedora-Cloud-Base-*-x86_64-*" |
| 65 | + name: "RHEL-10*HVM*x86_64*" |
64 | 66 | architecture: "x86_64" |
65 | 67 | virtualization-type: "hvm" |
66 | 68 | root-device-type: "ebs" |
| 69 | + block-device-mapping.volume-type: |
| 70 | + - "gp3" |
| 71 | + - "gp2" |
67 | 72 | state: "available" |
68 | | - register: fedora_ami_info |
| 73 | + register: rhel_ami_info |
69 | 74 |
|
70 | | - - name: Fail if no Fedora AMI found |
| 75 | + - name: Fail if no RHEL 10 AMI found |
71 | 76 | ansible.builtin.fail: |
72 | | - msg: "No Fedora Cloud Base AMI found in {{ aws_region }}. Try a different region or adjust filters." |
73 | | - when: fedora_ami_info.images | length == 0 |
| 77 | + msg: >- |
| 78 | + No RHEL 10 (HVM, SSD) AMI found in {{ aws_region }}. |
| 79 | + If you are not subscribed, go to AWS Marketplace and subscribe to |
| 80 | + "Red Hat Enterprise Linux 10 (HVM), SSD Volume Type", then retry. |
| 81 | + when: rhel_ami_info.images | length == 0 |
74 | 82 |
|
75 | | - - name: Pick most recent Fedora AMI by creation date |
| 83 | + - name: Pick most recent RHEL 10 AMI by creation date |
76 | 84 | ansible.builtin.set_fact: |
77 | | - fedora_ami: "{{ (fedora_ami_info.images | sort(attribute='creation_date')) | last }}" |
| 85 | + rhel_ami: "{{ (rhel_ami_info.images | sort(attribute='creation_date')) | last }}" |
78 | 86 |
|
79 | 87 | - name: Check for existing instance by Name tag |
80 | 88 | amazon.aws.ec2_instance_info: |
|
93 | 101 | name: "{{ instance_name }}" |
94 | 102 | region: "{{ aws_region }}" |
95 | 103 | instance_type: "{{ instance_type }}" |
96 | | - image_id: "{{ fedora_ami.image_id }}" |
| 104 | + image_id: "{{ rhel_ami.image_id }}" |
97 | 105 | security_group: "{{ sg.group_id | default(sg.results[0].group_id) }}" |
98 | 106 | subnet_id: "{{ subnets.subnets[0].id }}" |
99 | 107 | wait: true |
|
0 commit comments