Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for devuan linux distribution #2553

Merged
merged 6 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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+
#

narrieta marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not recommend disabling this, what is the motivation for defaulting to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Norberto, thanks for looking into the changes for this pull request.

I based the default waagent.conf for devuan on the one for debian, and this appears to be the only one in which OS.EnableFirewall is disabled. I'm happy to enable it in the waagent.conf for devuan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just uploaded three changes to the devuan_support_new branch. The changes include setting waagent.conf to default to OS.EnableFirewall to y


# 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