Skip to content

Commit 7c1d27b

Browse files
authored
Add Rocky Linux support to cloud-init (canonical#906)
Rocky Linux is a RHEL-compatible distribution so all changes that have been made should be trivial.
1 parent c8db603 commit 7c1d27b

File tree

15 files changed

+61
-16
lines changed

15 files changed

+61
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ get in contact with that distribution and send them our way!
3939

4040
| Supported OSes | Supported Public Clouds | Supported Private Clouds |
4141
| --- | --- | --- |
42-
| Alpine Linux<br />ArchLinux<br />Debian<br />Fedora<br />FreeBSD<br />Gentoo Linux<br />NetBSD<br />OpenBSD<br />RHEL/CentOS/AlmaLinux<br />SLES/openSUSE<br />Ubuntu<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | Amazon Web Services<br />Microsoft Azure<br />Google Cloud Platform<br />Oracle Cloud Infrastructure<br />Softlayer<br />Rackspace Public Cloud<br />IBM Cloud<br />Digital Ocean<br />Bigstep<br />Hetzner<br />Joyent<br />CloudSigma<br />Alibaba Cloud<br />OVH<br />OpenNebula<br />Exoscale<br />Scaleway<br />CloudStack<br />AltCloud<br />SmartOS<br />HyperOne<br />Vultr<br />Rootbox<br /> | Bare metal installs<br />OpenStack<br />LXD<br />KVM<br />Metal-as-a-Service (MAAS)<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />|
42+
| Alpine Linux<br />ArchLinux<br />Debian<br />Fedora<br />FreeBSD<br />Gentoo Linux<br />NetBSD<br />OpenBSD<br />RHEL/CentOS/AlmaLinux/Rocky<br />SLES/openSUSE<br />Ubuntu<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> | Amazon Web Services<br />Microsoft Azure<br />Google Cloud Platform<br />Oracle Cloud Infrastructure<br />Softlayer<br />Rackspace Public Cloud<br />IBM Cloud<br />Digital Ocean<br />Bigstep<br />Hetzner<br />Joyent<br />CloudSigma<br />Alibaba Cloud<br />OVH<br />OpenNebula<br />Exoscale<br />Scaleway<br />CloudStack<br />AltCloud<br />SmartOS<br />HyperOne<br />Vultr<br />Rootbox<br /> | Bare metal installs<br />OpenStack<br />LXD<br />KVM<br />Metal-as-a-Service (MAAS)<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />|
4343

4444
## To start developing cloud-init
4545

cloudinit/config/cc_ntp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
NTP_CONF = '/etc/ntp.conf'
2626
NR_POOL_SERVERS = 4
2727
distros = ['almalinux', 'alpine', 'centos', 'debian', 'fedora', 'opensuse',
28-
'rhel', 'sles', 'ubuntu']
28+
'rhel', 'rocky', 'sles', 'ubuntu']
2929

3030
NTP_CLIENT_CONFIG = {
3131
'chrony': {

cloudinit/config/cc_yum_add_repo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
**Module frequency:** per always
2020
21-
**Supported distros:** almalinux, centos, fedora, rhel
21+
**Supported distros:** almalinux, centos, fedora, rhel, rocky
2222
2323
**Config keys**::
2424
@@ -36,7 +36,7 @@
3636

3737
from cloudinit import util
3838

39-
distros = ['almalinux', 'centos', 'fedora', 'rhel']
39+
distros = ['almalinux', 'centos', 'fedora', 'rhel', 'rocky']
4040

4141

4242
def _canonicalize_id(repo_id):

cloudinit/distros/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
'debian': ['debian', 'ubuntu'],
4747
'freebsd': ['freebsd'],
4848
'gentoo': ['gentoo'],
49-
'redhat': ['almalinux', 'amazon', 'centos', 'fedora', 'rhel'],
49+
'redhat': ['almalinux', 'amazon', 'centos', 'fedora', 'rhel', 'rocky'],
5050
'suse': ['opensuse', 'sles'],
5151
}
5252

cloudinit/distros/rocky.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This file is part of cloud-init. See LICENSE file for license information.
2+
3+
from cloudinit.distros import rhel
4+
5+
6+
class Distro(rhel.Distro):
7+
pass
8+
9+
# vi: ts=4 expandtab

cloudinit/net/sysconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
LOG = logging.getLogger(__name__)
2121
NM_CFG_FILE = "/etc/NetworkManager/NetworkManager.conf"
22-
KNOWN_DISTROS = ['almalinux', 'centos', 'fedora', 'rhel', 'suse']
22+
KNOWN_DISTROS = ['almalinux', 'centos', 'fedora', 'rhel', 'rocky', 'suse']
2323

2424

2525
def _make_header(sep='#'):

cloudinit/tests/.test_util.py.swp

16 KB
Binary file not shown.

cloudinit/tests/test_util.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@
124124
ALMALINUX_MANTISBT_PROJECT_VERSION="8.3"
125125
""")
126126

127+
OS_RELEASE_ROCKY_8 = dedent("""\
128+
NAME="Rocky Linux"
129+
VERSION="8.3 (Green Obsidian)"
130+
ID="rocky"
131+
ID_LIKE="rhel fedora"
132+
VERSION_ID="8.3"
133+
PLATFORM_ID="platform:el8"
134+
PRETTY_NAME="Rocky Linux 8.3 (Green Obsidian)"
135+
ANSI_COLOR="0;31"
136+
CPE_NAME="cpe:/o:rocky:rocky:8"
137+
HOME_URL="https://rockylinux.org/"
138+
BUG_REPORT_URL="https://bugs.rockylinux.org/"
139+
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
140+
ROCKY_SUPPORT_PRODUCT_VERSION="8"
141+
""")
142+
127143
REDHAT_RELEASE_CENTOS_6 = "CentOS release 6.10 (Final)"
128144
REDHAT_RELEASE_CENTOS_7 = "CentOS Linux release 7.5.1804 (Core)"
129145
REDHAT_RELEASE_REDHAT_6 = (
@@ -132,7 +148,8 @@
132148
"Red Hat Enterprise Linux Server release 7.5 (Maipo)")
133149
REDHAT_RELEASE_ALMALINUX_8 = (
134150
"AlmaLinux release 8.3 (Purple Manul)")
135-
151+
REDHAT_RELEASE_ROCKY_8 = (
152+
"Rocky Linux release 8.3 (Green Obsidian)")
136153

137154
OS_RELEASE_DEBIAN = dedent("""\
138155
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
@@ -537,6 +554,22 @@ def test_get_linux_almalinux8_osrelease(self, m_os_release, m_path_exists):
537554
dist = util.get_linux_distro()
538555
self.assertEqual(('almalinux', '8.3', 'Purple Manul'), dist)
539556

557+
@mock.patch('cloudinit.util.load_file')
558+
def test_get_linux_rocky8_rhrelease(self, m_os_release, m_path_exists):
559+
"""Verify rocky linux 8 read from redhat-release."""
560+
m_os_release.return_value = REDHAT_RELEASE_ROCKY_8
561+
m_path_exists.side_effect = TestGetLinuxDistro.redhat_release_exists
562+
dist = util.get_linux_distro()
563+
self.assertEqual(('rocky', '8.3', 'Green Obsidian'), dist)
564+
565+
@mock.patch('cloudinit.util.load_file')
566+
def test_get_linux_rocky8_osrelease(self, m_os_release, m_path_exists):
567+
"""Verify rocky linux 8 read from os-release."""
568+
m_os_release.return_value = OS_RELEASE_ROCKY_8
569+
m_path_exists.side_effect = TestGetLinuxDistro.os_release_exists
570+
dist = util.get_linux_distro()
571+
self.assertEqual(('rocky', '8.3', 'Green Obsidian'), dist)
572+
540573
@mock.patch('cloudinit.util.load_file')
541574
def test_get_linux_debian(self, m_os_release, m_path_exists):
542575
"""Verify we get the correct name and release name on Debian."""

cloudinit/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def system_info():
522522
linux_dist = info['dist'][0].lower()
523523
if linux_dist in (
524524
'almalinux', 'alpine', 'arch', 'centos', 'debian', 'fedora',
525-
'rhel', 'suse'):
525+
'rhel', 'rocky', 'suse'):
526526
var = linux_dist
527527
elif linux_dist in ('ubuntu', 'linuxmint', 'mint'):
528528
var = 'ubuntu'

config/cloud.cfg.tmpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ disable_root: false
2121
disable_root: true
2222
{% endif %}
2323

24-
{% if variant in ["almalinux", "alpine", "amazon", "centos", "fedora", "rhel"] %}
24+
{% if variant in ["almalinux", "alpine", "amazon", "centos", "fedora",
25+
"rhel", "rocky"] %}
2526
mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
2627
{% if variant == "amazon" %}
2728
resize_rootfs: noblock
@@ -154,7 +155,7 @@ cloud_final_modules:
154155
system_info:
155156
# This will affect which distro class gets used
156157
{% if variant in ["almalinux", "alpine", "amazon", "arch", "centos", "debian",
157-
"fedora", "freebsd", "netbsd", "openbsd", "rhel",
158+
"fedora", "freebsd", "netbsd", "openbsd", "rhel", "rocky",
158159
"suse", "ubuntu"] %}
159160
distro: {{ variant }}
160161
{% else %}
@@ -207,7 +208,7 @@ system_info:
207208
security: http://ports.ubuntu.com/ubuntu-ports
208209
ssh_svcname: ssh
209210
{% elif variant in ["almalinux", "alpine", "amazon", "arch", "centos", "fedora",
210-
"rhel", "suse"] %}
211+
"rhel", "rocky", "suse"] %}
211212
# Default user name + that default users groups (if added/used)
212213
default_user:
213214
{% if variant == "amazon" %}

0 commit comments

Comments
 (0)