Skip to content

Commit 18c8830

Browse files
authored
Enable Amazon Linux to yum_add_repo and ca_certs. (#6767)
Adding amazon linux variant to cloud config. And Refreshing/Updating module values for Amazon Linux distro only. Namely cc_ca_cert and cc_yum_add_repo.
1 parent 207d38f commit 18c8830

3 files changed

Lines changed: 22 additions & 47 deletions

File tree

cloudinit/config/cc_ca_certs.py

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@
3030
"ca_cert_config": "/etc/ca-certificates/conf.d/cloud-init.conf",
3131
"ca_cert_update_cmd": ["update-ca-bundle"],
3232
},
33-
"fedora": {
34-
"ca_cert_path": "/etc/pki/ca-trust/",
35-
"ca_cert_local_path": "/usr/share/pki/ca-trust-source/",
36-
"ca_cert_filename": "anchors/cloud-init-ca-cert-{cert_index}.crt",
37-
"ca_cert_config": None,
38-
"ca_cert_update_cmd": ["update-ca-trust"],
39-
},
4033
"rhel": {
4134
"ca_cert_path": "/etc/pki/ca-trust/",
4235
"ca_cert_local_path": "/usr/share/pki/ca-trust-source/",
@@ -60,42 +53,28 @@
6053
},
6154
}
6255

63-
for distro in (
64-
"opensuse-microos",
65-
"opensuse-tumbleweed",
66-
"opensuse-leap",
67-
"sle_hpc",
68-
"sle-micro",
69-
"sles",
70-
):
71-
DISTRO_OVERRIDES[distro] = DISTRO_OVERRIDES["opensuse"]
72-
73-
for distro in (
74-
"almalinux",
75-
"centos",
76-
"cloudlinux",
77-
"rocky",
78-
):
79-
DISTRO_OVERRIDES[distro] = DISTRO_OVERRIDES["rhel"]
80-
81-
distros = [
82-
"almalinux",
56+
DISTRO_FAMILY = {
57+
"almalinux": "rhel",
58+
"amazon": "rhel",
59+
"centos": "rhel",
60+
"cloudlinux": "rhel",
61+
"fedora": "rhel",
62+
"opensuse-microos": "opensuse",
63+
"opensuse-tumbleweed": "opensuse",
64+
"opensuse-leap": "opensuse",
65+
"rocky": "rhel",
66+
"sle_hpc": "opensuse",
67+
"sle-micro": "opensuse",
68+
"sles": "opensuse",
69+
}
70+
71+
distros = list(DISTRO_FAMILY.keys()) + [
8372
"aosc",
84-
"centos",
85-
"cloudlinux",
8673
"alpine",
8774
"debian",
88-
"fedora",
8975
"raspberry-pi-os",
9076
"rhel",
91-
"rocky",
9277
"opensuse",
93-
"opensuse-microos",
94-
"opensuse-tumbleweed",
95-
"opensuse-leap",
96-
"sle_hpc",
97-
"sle-micro",
98-
"sles",
9978
"ubuntu",
10079
"photon",
10180
]
@@ -114,6 +93,8 @@ def _distro_ca_certs_configs(distro_name):
11493
@param distro_name: String providing the distro class name.
11594
@returns: Dict of distro configurations for ca_cert.
11695
"""
96+
if distro_name in DISTRO_FAMILY:
97+
distro_name = DISTRO_FAMILY[distro_name]
11798
cfg = DISTRO_OVERRIDES.get(distro_name, DEFAULT_CONFIG)
11899
cfg["ca_cert_full_path"] = os.path.join(
119100
cfg["ca_cert_local_path"], cfg["ca_cert_filename"]
@@ -160,7 +141,7 @@ def disable_default_ca_certs(distro_name, distro_cfg):
160141
@param distro_name: String providing the distro class name.
161142
@param distro_cfg: A hash providing _distro_ca_certs_configs function.
162143
"""
163-
if distro_name in ["rhel", "photon"]:
144+
if distro_name in ["rhel", "photon", "amazon"]:
164145
remove_default_ca_certs(distro_cfg)
165146
elif distro_name in [
166147
"alpine",

cloudinit/config/cc_yum_add_repo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"id": "cc_yum_add_repo",
2222
"distros": [
2323
"almalinux",
24+
"amazon",
2425
"azurelinux",
2526
"centos",
2627
"cloudlinux",

config/cloud.cfg.tmpl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,6 @@ apt:
9797
# timeout: 5 # (defaults to 50 seconds)
9898
# max_wait: 10 # (defaults to 120 seconds)
9999

100-
{% if variant == "amazon" %}
101-
# Amazon Linux relies on ec2-net-utils for network configuration
102-
network:
103-
config: disabled
104-
105-
{% endif -%}
106-
107100
{% if is_rhel %}
108101
# Default redhat settings:
109102
ssh_deletekeys: true
@@ -168,12 +161,12 @@ cloud_config_modules:
168161
{% if variant == "ubuntu" %}
169162
- ubuntu_pro
170163
{% endif %}
171-
{% elif variant in ["azurelinux", "fedora", "mariner", "openeuler",
164+
{% elif variant in ["amazon", "azurelinux", "fedora", "mariner", "openeuler",
172165
"openmandriva", "photon"] or is_rhel %}
173166
{% if is_rhel %}
174167
- rh_subscription
175168
{% endif %}
176-
{% if variant not in ["azurelinux", "mariner", "photon"] %}
169+
{% if variant not in ["amazon", "azurelinux", "mariner", "photon"] %}
177170
- spacewalk
178171
{% endif %}
179172
- yum_add_repo

0 commit comments

Comments
 (0)