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

Ubuntu/devel #1921

Merged
merged 36 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f1a9e44
Docs: adding relative links
s-makin Nov 22, 2022
65eb520
Make 3.12 failures not fail the build (#1873)
TheRealFalcon Nov 23, 2022
4ba809b
status: handle ds not defined in status.json (#1876)
aciba90 Nov 23, 2022
893df0d
Release 22.4.2 (#1878)
blackboxsw Nov 24, 2022
871edd5
Add support for static IPv6 addresses for FreeBSD (#1839)
einsibjarni Nov 26, 2022
198303e
test: fix lxd preseed managed network config (#1881)
aciba90 Nov 28, 2022
6795bb8
docs: uprate analyze to performance page
s-makin Nov 29, 2022
68b9471
feat: add support aliyun metadata security harden mode (#1865)
ManassehZhou Nov 30, 2022
7a93f1c
FreeBSD init: use cloudinit_enable as only rcvar (#1875)
igalic Nov 30, 2022
5e6ecc6
Append derivatives to is_rhel list in cloud.cfg.tmpl (#1887)
nazunalika Dec 2, 2022
b12342e
Fix exception in BSD networking code-path (#1894)
igalic Dec 7, 2022
aecdcbf
Add support for setting uid when creating users on FreeBSD (#1888)
einsibjarni Dec 7, 2022
c273d0e
lint: fix tip-flake8 and tip-mypy (#1896)
aciba90 Dec 7, 2022
9446bdb
doc: add qemu tutorial (#1863)
holmanb Dec 7, 2022
f75be2e
networkd: Add support for multiple [Route] sections (#1868)
nkukard Dec 7, 2022
8ee0d21
Add back gateway4/6 deprecation to docs (#1898)
TheRealFalcon Dec 8, 2022
9329c53
sources/azure: encode health report as utf-8 (#1897)
cjp256 Dec 8, 2022
9bb3ee6
autoinstall: clarify docs for users
holmanb Dec 9, 2022
bbf200f
* net: netplan config root read-only as wifi config can contain creds
blackboxsw Dec 9, 2022
dc1d27b
pycloudlib: bump commit dropping azure api smoke test
blackboxsw Dec 9, 2022
a6fd6ef
Fix the distro.osfamily output problem in the openEuler system. (#1895)
xiaoge1001 Dec 12, 2022
a177e07
Networking Clarification (#1892)
holmanb Dec 12, 2022
a71e531
azure: fix support for systems without az command installed (#1908)
blackboxsw Dec 12, 2022
9e6f7ed
netplan: define features.NETPLAN_CONFIG_ROOT_READ_ONLY flag
blackboxsw Dec 12, 2022
30e5f00
docs: add copy button to code blocks (#1890)
s-makin Dec 13, 2022
6e725f3
Ensure network ready before cloud-init service runs on RHEL (#1893)
TheRealFalcon Dec 13, 2022
f105331
test: mock file deletion in dhcp tests (#1911)
holmanb Dec 13, 2022
0bfed1d
add utility function test cases (#1910)
xiaoge1001 Dec 14, 2022
5f5c3e1
mounts: document weird prefix in schema (#1913)
holmanb Dec 15, 2022
6bdd88a
read-version: When insufficient tags, use cloudinit.version.get_version
blackboxsw Dec 15, 2022
99c0750
doc: improve cc_write_files doc (#1916)
aciba90 Dec 15, 2022
3a22320
tools: read-version drop extra call to git describe --long
blackboxsw Dec 15, 2022
040090a
nocloud: add support for dmi variable expansion for seedfrom URL
blackboxsw Dec 15, 2022
7cd6874
merge from upstream/main at 22.4-49-g040090a3
blackboxsw Dec 15, 2022
78f631a
update changelog (new upstream snapshot)
blackboxsw Dec 15, 2022
c13bf73
releasing cloud-init version 22.4.2-0ubuntu2
blackboxsw Dec 15, 2022
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
2 changes: 1 addition & 1 deletion cloudinit/config/cc_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def install(self, pkg_name: str):
if not self.is_installed():
# bootstrap pip if required
try:
import pip # type: ignore # noqa: F401
import pip # noqa: F401
except ImportError:
self.distro.install_packages(self.distro.pip_package_name)
cmd = [sys.executable, "-m", "pip", "install"]
Expand Down
9 changes: 6 additions & 3 deletions cloudinit/config/cc_write_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@
before being written. For empty file creation, content can be omitted.

.. note::
if multiline data is provided, care should be taken to ensure that it
follows yaml formatting standards. to specify binary data, use the yaml
If multiline data is provided, care should be taken to ensure that it
follows yaml formatting standards. To specify binary data, use the yaml
option ``!!binary``

.. note::
Do not write files under /tmp during boot because of a race with
systemd-tmpfiles-clean that can cause temp files to get cleaned during
the early boot process. Use /run/somedir instead to avoid race
LP:1707222."""
LP:1707222.

.. warning::
Existing files will be overridden."""
),
"distros": ["all"],
"examples": [
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def validate_cloudconfig_metaschema(validator, schema: dict, throw=True):

def validate_cloudconfig_schema(
config: dict,
schema: dict = None,
schema: Optional[dict] = None,
strict: bool = False,
strict_metaschema: bool = False,
log_details: bool = True,
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/config/schemas/schema-cloud-config-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,7 @@
"description": "Path to the swap file to create"
},
"size": {
"description": "The size in bytes of the swap file, 'auto' or a human-readable size abbreviation of the format <float_size><units> where units are one of B, K, M, G or T.",
"description": "The size in bytes of the swap file, 'auto' or a human-readable size abbreviation of the format <float_size><units> where units are one of B, K, M, G or T. **WARNING: Attempts to use IEC prefixes in your configuration prior to cloud-init version 23.1 will result in unexpected behavior. SI prefixes names (KB, MB) are required on pre-23.1 cloud-init, however IEC values are used. In summary, assume 1KB == 1024B, not 1000B**",
"oneOf": [
{
"enum": [
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/distros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
"fedora",
"mariner",
"miraclelinux",
"openEuler",
"openmandriva",
"photon",
"rhel",
"rocky",
"virtuozzo",
],
"suse": ["opensuse", "sles"],
"openEuler": ["openEuler"],
}

LOG = logging.getLogger(__name__)
Expand Down
5 changes: 3 additions & 2 deletions cloudinit/distros/freebsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def add_user(self, name, **kwargs):
"groups": "-G",
"shell": "-s",
"inactive": "-E",
"uid": "-u",
}
pw_useradd_flags = {
"no_user_group": "--no-user-group",
Expand All @@ -84,8 +85,8 @@ def add_user(self, name, **kwargs):
}

for key, val in kwargs.items():
if key in pw_useradd_opts and val and isinstance(val, str):
pw_useradd_cmd.extend([pw_useradd_opts[key], val])
if key in pw_useradd_opts and val and isinstance(val, (str, int)):
pw_useradd_cmd.extend([pw_useradd_opts[key], str(val)])

elif key in pw_useradd_flags and val:
pw_useradd_cmd.append(pw_useradd_flags[key])
Expand Down
1 change: 1 addition & 0 deletions cloudinit/distros/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def __init__(self):
self.ifc = ifconfig.Ifconfig()
self.ifs = {}
self._update_ifs()
super().__init__()

def _update_ifs(self):
ifconf = subp.subp(["ifconfig", "-a"])
Expand Down
4 changes: 3 additions & 1 deletion cloudinit/distros/openEuler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@


class Distro(rhel.Distro):
pass
def __init__(self, name, cfg, paths):
super(Distro, self).__init__(name, cfg, paths)
self.osfamily = "openEuler"


# vi: ts=4 expandtab
28 changes: 28 additions & 0 deletions cloudinit/dmi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file is part of cloud-init. See LICENSE file for license information.
import os
import re
from collections import namedtuple
from typing import Optional

Expand Down Expand Up @@ -182,4 +183,31 @@ def is_x86(arch):
return None


def sub_dmi_vars(src: str) -> str:
"""Replace __dmi.VARNAME__ with DMI values from either sysfs or kenv."""
if "__" not in src:
return src
valid_dmi_keys = DMIDECODE_TO_KERNEL.keys()
for match in re.findall(r"__dmi\.([^_]+)__", src):
if match not in valid_dmi_keys:
LOG.warning(
"Ignoring invalid __dmi.%s__ in %s. Expected one of: %s.",
match,
src,
valid_dmi_keys,
)
continue
dmi_value = read_dmi_data(match)
if not dmi_value:
dmi_value = ""
LOG.debug(
"Replacing __dmi.%s__ in '%s' with '%s'.",
match,
src,
dmi_value,
)
src = src.replace(f"__dmi.{match}__", dmi_value)
return src


# vi: ts=4 expandtab
21 changes: 21 additions & 0 deletions cloudinit/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,27 @@
(This flag can be removed after Jammy is no longer supported.)
"""

NETPLAN_CONFIG_ROOT_READ_ONLY = True
"""
If ``NETPLAN_CONFIG_ROOT_READ_ONLY`` is True, then netplan configuration will
be written as a single root readon-only file /etc/netplan/50-cloud-init.yaml.
This prevents wifi passwords in network v2 configuration from being
world-readable. Prior to 23.1, netplan configuration is world-readable.

(This flag can be removed after Jammy is no longer supported.)
"""


NOCLOUD_SEED_URL_APPEND_FORWARD_SLASH = True
"""
Append a forward slash '/' if NoCloud seedurl does not end with either
a querystring or forward slash. Prior to 23.1, nocloud seedurl would be used
unaltered, appending meta-data, user-data and vendor-data to without URL path
separators.

(This flag can be removed when Jammy is no longer supported.)
"""

try:
# pylint: disable=wildcard-import
from cloudinit.feature_overrides import * # noqa
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/net/activators.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class IfUpDownActivator(NetworkActivator):
# E.g., NetworkManager has a ifupdown plugin that requires the name
# of a specific connection.
@staticmethod
def available(target: str = None) -> bool:
def available(target: Optional[str] = None) -> bool:
"""Return true if ifupdown can be used on this system."""
return eni_available(target=target)

Expand Down
66 changes: 53 additions & 13 deletions cloudinit/net/bsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, config=None):
config = {}
self.target = None
self.interface_configurations = {}
self.interface_configurations_ipv6 = {}
self._postcmds = config.get("postcmds", True)

def _ifconfig_entries(self, settings):
Expand Down Expand Up @@ -62,8 +63,6 @@ def _ifconfig_entries(self, settings):

LOG.info("Configuring interface %s", device_name)

self.interface_configurations[device_name] = "DHCP"

for subnet in interface.get("subnets", []):
if subnet.get("type") == "static":
if not subnet.get("netmask"):
Expand All @@ -85,29 +84,70 @@ def _ifconfig_entries(self, settings):
"mtu": subnet.get("mtu") or interface.get("mtu"),
}

elif subnet.get("type") == "static6":
if not subnet.get("prefix"):
LOG.debug(
"Skipping IP %s, because there is no prefix",
subnet.get("address"),
)
continue
LOG.debug(
"Configuring dev %s with %s / %s",
device_name,
subnet.get("address"),
subnet.get("prefix"),
)

self.interface_configurations_ipv6[device_name] = {
"address": subnet.get("address"),
"prefix": subnet.get("prefix"),
"mtu": subnet.get("mtu") or interface.get("mtu"),
}
elif (
subnet.get("type") == "dhcp"
or subnet.get("type") == "dhcp4"
):
self.interface_configurations[device_name] = "DHCP"

def _route_entries(self, settings):
routes = list(settings.iter_routes())
for interface in settings.iter_interfaces():
subnets = interface.get("subnets", [])
for subnet in subnets:
if subnet.get("type") != "static":
if subnet.get("type") == "static":
gateway = subnet.get("gateway")
if gateway and len(gateway.split(".")) == 4:
routes.append(
{
"network": "0.0.0.0",
"netmask": "0.0.0.0",
"gateway": gateway,
}
)
elif subnet.get("type") == "static6":
gateway = subnet.get("gateway")
if gateway and len(gateway.split(":")) > 1:
routes.append(
{
"network": "::",
"prefix": "0",
"gateway": gateway,
}
)
else:
continue
gateway = subnet.get("gateway")
if gateway and len(gateway.split(".")) == 4:
routes.append(
{
"network": "0.0.0.0",
"netmask": "0.0.0.0",
"gateway": gateway,
}
)
routes += subnet.get("routes", [])

for route in routes:
network = route.get("network")
if not network:
LOG.debug("Skipping a bad route entry")
continue
netmask = route.get("netmask")
netmask = (
route.get("netmask")
if route.get("netmask")
else route.get("prefix")
)
gateway = route.get("gateway")
self.set_route(network, netmask, gateway)

Expand Down
6 changes: 3 additions & 3 deletions cloudinit/net/ephemeral.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
import contextlib
import logging
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional

import cloudinit.net as net
from cloudinit import subp
Expand Down Expand Up @@ -35,7 +35,7 @@ def __init__(
prefix_or_mask,
broadcast,
router=None,
connectivity_url_data: Dict[str, Any] = None,
connectivity_url_data: Optional[Dict[str, Any]] = None,
static_routes=None,
):
"""Setup context manager and validate call signature.
Expand Down Expand Up @@ -313,7 +313,7 @@ class EphemeralDHCPv4:
def __init__(
self,
iface=None,
connectivity_url_data: Dict[str, Any] = None,
connectivity_url_data: Optional[Dict[str, Any]] = None,
dhcp_log_func=None,
tmp_dir=None,
):
Expand Down
23 changes: 21 additions & 2 deletions cloudinit/net/freebsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,31 @@ def rename_interface(self, cur_name, device_name):

def write_config(self):
for device_name, v in self.interface_configurations.items():
net_config = "DHCP"
if isinstance(v, dict):
net_config = v.get("address") + " netmask " + v.get("netmask")
net_config = "inet %s netmask %s" % (
v.get("address"),
v.get("netmask"),
)
mtu = v.get("mtu")
if mtu:
net_config += " mtu %d" % mtu
elif v == "DHCP":
net_config = "DHCP"
self.set_rc_config_value("ifconfig_" + device_name, net_config)

for device_name, v in self.interface_configurations_ipv6.items():
if isinstance(v, dict):
net_config = "inet6 %s/%d" % (
v.get("address"),
v.get("prefix"),
)
mtu = v.get("mtu")
if mtu:
net_config += " mtu %d" % mtu
self.set_rc_config_value(
"ifconfig_%s_ipv6" % device_name, net_config
)

def start_services(self, run=False):
if not run:
LOG.debug("freebsd generate postcmd disabled")
Expand Down Expand Up @@ -58,6 +75,8 @@ def start_services(self, run=False):
def set_route(self, network, netmask, gateway):
if network == "0.0.0.0":
self.set_rc_config_value("defaultrouter", gateway)
elif network == "::":
self.set_rc_config_value("ipv6_defaultrouter", gateway)
else:
route_name = "route_net%d" % self._route_cpt
route_cmd = "-route %s/%s %s" % (network, netmask, gateway)
Expand Down
5 changes: 4 additions & 1 deletion cloudinit/net/netplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import textwrap
from typing import Optional, cast

from cloudinit import features
from cloudinit import log as logging
from cloudinit import safeyaml, subp, util
from cloudinit.net import (
Expand Down Expand Up @@ -260,7 +261,9 @@ def render_network_state(

if not header.endswith("\n"):
header += "\n"
util.write_file(fpnplan, header + content)

mode = 0o600 if features.NETPLAN_CONFIG_ROOT_READ_ONLY else 0o644
util.write_file(fpnplan, header + content, mode=mode)

if self.clean_default:
_clean_default(target=target)
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/net/network_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def __init__(
self,
version=NETWORK_STATE_VERSION,
config=None,
renderer=None, # type: Optional[Renderer]
renderer: "Optional[Renderer]" = None,
):
self._version = version
self._config = config
Expand Down
Loading