Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions cloudinit/distros/azurelinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import logging

from cloudinit import subp, util
from cloudinit.distros import rhel
from cloudinit.net.netplan import CLOUDINIT_NETPLAN_FILE

Expand All @@ -22,8 +21,6 @@


class Distro(rhel.Distro):
usr_lib_exec = "/usr/lib"

def __init__(self, name, cfg, paths):
super().__init__(name, cfg, paths)
self.osfamily = "azurelinux"
Expand All @@ -45,30 +42,3 @@ def __init__(self, name, cfg, paths):
"postcmds": "True",
},
}

def package_command(self, command, args=None, pkgs=None):
if pkgs is None:
pkgs = []

if subp.which("dnf"):
LOG.debug("Using DNF for package management")
cmd = ["dnf"]
else:
LOG.debug("Using TDNF for package management")
cmd = ["tdnf"]
# Determines whether or not dnf/tdnf prompts for confirmation
# of critical actions. We don't want to prompt...
cmd.append("-y")

if args and isinstance(args, str):
cmd.append(args)
elif args and isinstance(args, list):
cmd.extend(args)

cmd.append(command)

pkglist = util.expand_package_list("%s-%s", pkgs)
cmd.extend(pkglist)

# Allow the output of this to flow outwards (ie not be captured)
subp.subp(cmd, capture=False)
16 changes: 6 additions & 10 deletions config/cloud.cfg.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"raspberry-pi-os": "Raspberry Pi OS",
"ubuntu": "Ubuntu", "unknown": "Ubuntu"}) %}
{% set groups = ({"alpine": "adm, wheel", "aosc": "wheel", "arch": "wheel, users",
"azurelinux": "wheel",
"debian": "adm, audio, cdrom, dialout, dip, floppy, netdev, plugdev, sudo, video",
"gentoo": "users, wheel", "mariner": "wheel",
"photon": "wheel",
Expand All @@ -25,7 +24,7 @@
{% set shells = ({"alpine": "/bin/ash", "dragonfly": "/bin/sh",
"freebsd": "/bin/tcsh", "netbsd": "/bin/sh",
"openbsd": "/bin/ksh"}) %}
{% set usernames = ({"amazon": "ec2-user", "centos": "cloud-user",
{% set usernames = ({"amazon": "ec2-user", "azurelinux": "azureuser", "centos": "cloud-user",
"openmandriva": "omv", "raspberry-pi-os": "pi",
"rhel": "cloud-user",
"unknown": "ubuntu"}) %}
Expand Down Expand Up @@ -61,7 +60,7 @@ disable_root: false
disable_root: true
{% endif %}

{%- if variant in ["alpine", "amazon", "fedora", "OpenCloudOS", "openeuler",
{%- if variant in ["alpine", "amazon", "azurelinux", "fedora", "OpenCloudOS", "openeuler",
"openmandriva", "photon", "TencentOS"] or is_rhel %}

{% if is_rhel %}
Expand Down Expand Up @@ -178,9 +177,7 @@ cloud_config_modules:
{% if variant == "raspberry-pi-os" %}
- raspberry_pi
{% endif %}
{% if variant not in ["azurelinux"] %}
- disable_ec2_metadata
{% endif %}
- runcmd
{% if variant in ["debian", "ubuntu", "unknown"] %}
- byobu
Expand All @@ -198,17 +195,13 @@ cloud_final_modules:
- ubuntu_drivers
{% endif %}
- write_files_deferred
{% if variant not in ["azurelinux"] %}
- puppet
- chef
{% endif %}
- ansible
{% if variant not in ["azurelinux"] %}
- mcollective
- salt_minion
{% if variant not in ["alpine"] %}
- reset_rmc
{% endif %}
{% endif %}
- scripts_vendor
- scripts_per_once
Expand Down Expand Up @@ -287,6 +280,9 @@ system_info:
{% if variant == "alpine" %}
network:
renderers: ['eni']
{% elif variant == "azurelinux" %}
network:
renderers: ['netplan', 'networkd', 'network-manager']
{% elif variant == "debian" %}
network:
renderers: ['netplan', 'eni', 'networkd']
Expand All @@ -300,7 +296,7 @@ system_info:
{% elif variant in ["freebsd", "netbsd", "openbsd"] %}
network:
renderers: ['{{ variant }}']
{% elif variant in ["azurelinux", "mariner", "photon"] %}
{% elif variant in ["mariner", "photon"] %}
network:
renderers: ['networkd']
{% elif variant == "openmandriva" %}
Expand Down
2 changes: 1 addition & 1 deletion systemd/cloud-init-generator.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CLOUD_SYSTEM_TARGET="/usr/lib/systemd/system/cloud-init.target"
{% else %}
CLOUD_SYSTEM_TARGET="/lib/systemd/system/cloud-init.target"
{% endif %}
{% if variant in ["almalinux", "centos", "cloudlinux", "eurolinux", "fedora",
{% if variant in ["almalinux", "azurelinux", "centos", "cloudlinux", "eurolinux", "fedora",
"miraclelinux", "openeuler", "OpenCloudOS", "openmandriva", "rhel", "rocky", "TencentOS", "virtuozzo"] %}
dsidentify="/usr/libexec/cloud-init/ds-identify"
{% elif variant == "benchmark" %}
Expand Down
6 changes: 3 additions & 3 deletions systemd/cloud-init-local.service.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
[Unit]
# https://docs.cloud-init.io/en/latest/explanation/boot.html
Description=Cloud-init: Local Stage (pre-network)
{% if variant in ["almalinux", "cloudlinux", "ubuntu", "unknown", "debian", "raspberry-pi-os", "rhel"] %}
{% if variant in ["almalinux", "azurelinux", "cloudlinux", "ubuntu", "unknown", "debian", "raspberry-pi-os", "rhel"] %}
DefaultDependencies=no
{% endif %}
Wants=network-pre.target
After=hv_kvp_daemon.service
Before=network-pre.target
Before=shutdown.target
{% if variant in ["almalinux", "cloudlinux", "rhel"] %}
{% if variant in ["almalinux", "azurelinux", "cloudlinux", "rhel"] %}
Before=firewalld.target
{% endif %}
{% if variant in ["ubuntu", "unknown", "debian", "raspberry-pi-os"] %}
Expand All @@ -22,7 +22,7 @@ ConditionEnvironment=!KERNEL_CMDLINE=cloud-init=disabled

[Service]
Type=oneshot
{% if variant in ["almalinux", "cloudlinux", "rhel"] %}
{% if variant in ["almalinux", "azurelinux", "cloudlinux", "rhel"] %}
ExecStartPre=/sbin/restorecon /run/cloud-init
{% endif %}
# This service is a shim which preserves systemd ordering while allowing a
Expand Down
6 changes: 3 additions & 3 deletions systemd/cloud-init-main.service.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
# https://www.freedesktop.org/software/systemd/man/latest/systemd-remount-fs.service.html
[Unit]
Description=Cloud-init: Single Process
{% if variant in ["almalinux", "cloudlinux", "ubuntu", "unknown", "debian", "raspberry-pi-os", "rhel"] %}
{% if variant in ["almalinux", "azurelinux", "cloudlinux", "ubuntu", "unknown", "debian", "raspberry-pi-os", "rhel"] %}
DefaultDependencies=no
{% endif %}
{% if variant in ["almalinux", "cloudlinux", "rhel"] %}
{% if variant in ["almalinux", "azurelinux", "cloudlinux", "rhel"] %}
Requires=dbus.socket
After=dbus.socket
{% endif %}
Expand All @@ -31,7 +31,7 @@ ExecStart=/usr/bin/cloud-init --all-stages
KillMode=process
TasksMax=infinity
TimeoutStartSec=infinity
{% if variant in ["almalinux", "cloudlinux", "rhel"] %}
{% if variant in ["almalinux", "azurelinux", "cloudlinux", "rhel"] %}
ExecStartPre=/sbin/restorecon /run/cloud-init
{% endif %}

Expand Down
4 changes: 2 additions & 2 deletions systemd/cloud-init-network.service.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[Unit]
# https://docs.cloud-init.io/en/latest/explanation/boot.html
Description=Cloud-init: Network Stage
{% if variant not in ["almalinux", "cloudlinux", "photon", "rhel"] %}
{% if variant not in ["almalinux", "azurelinux", "cloudlinux", "photon", "rhel"] %}
DefaultDependencies=no
{% endif %}
Wants=cloud-init-local.service
Expand All @@ -15,7 +15,7 @@ After=systemd-networkd-wait-online.service
{% if variant in ["ubuntu", "unknown", "debian", "raspberry-pi-os"] %}
After=networking.service
{% endif %}
{% if variant in ["almalinux", "centos", "cloudlinux", "eurolinux", "fedora",
{% if variant in ["almalinux", "azurelinux", "centos", "cloudlinux", "eurolinux", "fedora",
"miraclelinux", "openeuler", "OpenCloudOS", "openmandriva",
"rhel", "rocky", "suse", "TencentOS", "virtuozzo"] %}
After=NetworkManager.service
Expand Down
1 change: 1 addition & 0 deletions templates/hosts.azurelinux.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ you need to add the following to config:

# The following lines are desirable for IPv6 capable hosts
::1 {{fqdn}} {{hostname}}
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
1 change: 1 addition & 0 deletions tests/unittests/test_render_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def test_variant_sets_default_user_in_cloud_cfg(self, variant, tmpdir):

default_user_exceptions = {
"amazon": "ec2-user",
"azurelinux": "azureuser",
"rhel": "cloud-user",
"centos": "cloud-user",
"raspberry-pi-os": "pi",
Expand Down
22 changes: 15 additions & 7 deletions tests/unittests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,23 @@

OS_RELEASE_AZURELINUX = dedent(
"""\
NAME="Microsoft Azure Linux"
VERSION="3.0.20240206"
NAME="Azure Linux"
VERSION="4.0 (Cloud Variant)"
RELEASE_TYPE=stable
ID=azurelinux
VERSION_ID="3.0"
PRETTY_NAME="Microsoft Azure Linux 3.0"
ANSI_COLOR="1;34"
ID_LIKE=fedora
VERSION_ID=4.0
VERSION_CODENAME=""
PRETTY_NAME="Azure Linux 4.0 (Cloud Variant)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=azurelinux-logo-icon
CPE_NAME="cpe:/o:microsoft:azurelinux:4.0"
HOME_URL="https://aka.ms/azurelinux"
BUG_REPORT_URL="https://aka.ms/azurelinux"
DOCUMENTATION_URL="https://aka.ms/azurelinux"
SUPPORT_URL="https://aka.ms/azurelinux"
BUG_REPORT_URL="https://aka.ms/azurelinux"
VARIANT="Cloud Variant"
VARIANT_ID=cloud
"""
)

Expand Down Expand Up @@ -1276,7 +1284,7 @@ def test_get_linux_azurelinux_os_release(
m_os_release.return_value = OS_RELEASE_AZURELINUX
m_path_exists.side_effect = TestGetLinuxDistro.os_release_exists
dist = util.get_linux_distro()
assert ("azurelinux", "3.0", "") == dist
assert ("azurelinux", "4.0", "Cloud Variant") == dist

@mock.patch(M_PATH + "load_text_file")
def test_get_linux_openmandriva(self, m_os_release, m_path_exists):
Expand Down
Loading