Skip to content

Commit

Permalink
Added support for distro Devuan
Browse files Browse the repository at this point in the history
(Will only work with Devuan >= 4 (Chimaera) - reason is
that in Devuan < 4, the platform.linux_distribution module is
used to get distro details - and this module is unable to
distinguish between Debian and Devuan. In Chimaera, python3 is 3.9,
and in this, platform.linux_distribution has been removed, so that
distro details are obtained using distro.linux_distribution - which
is able to distinguish between Debian and Devuan)

Details:

- added azurelinuxagent/common/osutil/devuan.py
- modified azurelinuxagent/common/osutil/factory.py to use devuan.py
- added init and config files for devuan
- modified setup.py for devuan support
- modified tests/common/osutil/test_factory.py to test devuan support
  • Loading branch information
peter9370 committed Apr 20, 2022
1 parent 1da0ef6 commit d7b3d60
Show file tree
Hide file tree
Showing 7 changed files with 831 additions and 0 deletions.
64 changes: 64 additions & 0 deletions azurelinuxagent/common/osutil/devuan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
# Copyright 2018 Microsoft Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Requires Python 2.6+ and Openssl 1.0+
#

import os # pylint: disable=W0611
import re # pylint: disable=W0611
import pwd # pylint: disable=W0611
import shutil # pylint: disable=W0611
import socket # pylint: disable=W0611
import array # pylint: disable=W0611
import struct # pylint: disable=W0611
import fcntl # pylint: disable=W0611
import time # pylint: disable=W0611
import base64 # pylint: disable=W0611
import azurelinuxagent.common.logger as logger # pylint: disable=W0611
import azurelinuxagent.common.utils.fileutil as fileutil # pylint: disable=W0611
import azurelinuxagent.common.utils.shellutil as shellutil
import azurelinuxagent.common.utils.textutil as textutil # pylint: disable=W0611
from azurelinuxagent.common.osutil.default import DefaultOSUtil


class DevuanOSUtil(DefaultOSUtil):

def __init__(self):
super(DevuanOSUtil, self).__init__()
self.jit_enabled = True

def restart_ssh_service(self):
logger.info("DevuanOSUtil::restart_ssh_service - trying to restart sshd")
return shellutil.run("/usr/sbin/service restart ssh", chk_err=False)

def stop_agent_service(self):
logger.info("DevuanOSUtil::stop_agent_service - trying to stop waagent")
return shellutil.run("/usr/sbin/service walinuxagent stop", chk_err=False)

def start_agent_service(self):
logger.info("DevuanOSUtil::start_agent_service - trying to start waagent")
return shellutil.run("/usr/sbin/service walinuxagent start", chk_err=False)

def start_network(self):
pass

def remove_rules_files(self, rules_files=""):
pass

def restore_rules_files(self, rules_files=""):
pass

def get_dhcp_lease_endpoint(self):
return self.get_endpoint_from_leases_path('/var/lib/dhcp/dhclient.*.leases')
11 changes: 11 additions & 0 deletions azurelinuxagent/common/osutil/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .coreos import CoreOSUtil
from .debian import DebianOSBaseUtil, DebianOSModernUtil
from .default import DefaultOSUtil
from .devuan import DevuanOSUtil
from .freebsd import FreeBSDOSUtil
from .gaia import GaiaOSUtil
from .iosxe import IosxeOSUtil
Expand Down Expand Up @@ -102,6 +103,16 @@ def _get_osutil(distro_name, distro_code_name, distro_version, distro_full_name)

return DebianOSBaseUtil()

# Devuan support only works with v4+
# Reason is that Devuan v4 (Chimaera) uses python v3.9, in which the
# platform.linux_distribution module has been removed. This was unable
# to distinguish between debian and devuan. The new distro.linux_distribution module
# is able to distinguish between the two.

if distro_name == "devuan" and Version(distro_version) >= Version("4"):
return DevuanOSUtil()


if distro_name in ("redhat", "rhel", "centos", "oracle", "almalinux",
"cloudlinux", "rocky"):
if Version(distro_version) < Version("7"):
Expand Down
130 changes: 130 additions & 0 deletions config/devuan/waagent.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#
# Microsoft Azure Linux Agent Configuration
#

# Enable extension handling. Do not disable this unless you do not need password reset,
# backup, monitoring, or any extension handling whatsoever.
Extensions.Enabled=y

# Which provisioning agent to use. Supported values are "auto" (default), "waagent",
# "cloud-init", or "disabled".
Provisioning.Agent=auto

# Password authentication for root account will be unavailable.
Provisioning.DeleteRootPassword=y

# Generate fresh host key pair.
Provisioning.RegenerateSshHostKeyPair=y

# Supported values are "rsa", "dsa", "ecdsa", "ed25519", and "auto".
# The "auto" option is supported on OpenSSH 5.9 (2011) and later.
Provisioning.SshHostKeyPairType=auto

# Monitor host name changes and publish changes via DHCP requests.
Provisioning.MonitorHostName=y

# Decode CustomData from Base64.
Provisioning.DecodeCustomData=n

# Execute CustomData after provisioning.
Provisioning.ExecuteCustomData=n

# Algorithm used by crypt when generating password hash.
#Provisioning.PasswordCryptId=6

# Length of random salt used when generating password hash.
#Provisioning.PasswordCryptSaltLength=10

# Allow reset password of sys user
Provisioning.AllowResetSysUser=n

# Format if unformatted. If 'n', resource disk will not be mounted.
ResourceDisk.Format=y

# File system on the resource disk
# Typically ext3 or ext4. FreeBSD images should use 'ufs2' here.
ResourceDisk.Filesystem=ext4

# Mount point for the resource disk
ResourceDisk.MountPoint=/mnt/resource

# Create and use swapfile on resource disk.
ResourceDisk.EnableSwap=n

# Size of the swapfile.
ResourceDisk.SwapSizeMB=0

# Comma-separated list of mount options. See mount(8) for valid options.
ResourceDisk.MountOptions=None

# Enable verbose logging (y|n)
Logs.Verbose=n

# Enable Console logging, default is y
# Logs.Console=y

# Is FIPS enabled
OS.EnableFIPS=n

# Root device timeout in seconds.
OS.RootDeviceScsiTimeout=300

# If "None", the system default version is used.
OS.OpensslPath=None

# Set the SSH ClientAliveInterval
# OS.SshClientAliveInterval=180

# Set the path to SSH keys and configuration files
OS.SshDir=/etc/ssh

# If set, agent will use proxy server to access internet
#HttpProxy.Host=None
#HttpProxy.Port=None

# Detect Scvmm environment, default is n
# DetectScvmmEnv=n

#
# Lib.Dir=/var/lib/waagent

#
# DVD.MountPoint=/mnt/cdrom/secure

#
# Pid.File=/var/run/waagent.pid

#
# Extension.LogDir=/var/log/azure

#
# Home.Dir=/home

# Enable RDMA management and set up, should only be used in HPC images
# OS.EnableRDMA=y

# Enable or disable goal state processing auto-update, default is enabled
# AutoUpdate.Enabled=y

# Determine the update family, this should not be changed
# AutoUpdate.GAFamily=Prod

# Determine if the overprovisioning feature is enabled. If yes, hold extension
# handling until inVMArtifactsProfile.OnHold is false.
# Default is enabled
# EnableOverProvisioning=y

# Allow fallback to HTTP if HTTPS is unavailable
# Note: Allowing HTTP (vs. HTTPS) may cause security risks
# OS.AllowHTTP=n

# Add firewall rules to protect access to Azure host node services
# Note:
# - The default is false to protect the state of existing VMs
OS.EnableFirewall=n

# Enforce control groups limits on the agent and extensions
CGroups.EnforceLimits=n

# CGroups which are excluded from limits, comma separated
CGroups.Excluded=customscript,runcommand
2 changes: 2 additions & 0 deletions init/devuan/default/walinuxagent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# To disable the Microsoft Azure Agent, set WALINUXAGENT_ENABLED=0
WALINUXAGENT_ENABLED=1
Loading

0 comments on commit d7b3d60

Please sign in to comment.