curtin-dev team mailing list archive
-
curtin-dev team
-
Mailing list archive
-
Message #04127
[Merge] ~r00ta/curtin:maas-debian-cloudconfig-23.1 into curtin:release/23.1
Jacopo Rota has proposed merging ~r00ta/curtin:maas-debian-cloudconfig-23.1 into curtin:release/23.1.
Commit message:
curthooks: use cloudconfig to configure cloud-init on debian distros
Requested reviews:
curtin developers (curtin-dev)
For more details, see:
https://code.launchpad.net/~r00ta/curtin/+git/curtin/+merge/486476
--
Your team curtin developers is requested to review the proposed merge of ~r00ta/curtin:maas-debian-cloudconfig-23.1 into curtin:release/23.1.
diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py
index 48e45d5..ef17fc1 100644
--- a/curtin/commands/curthooks.py
+++ b/curtin/commands/curthooks.py
@@ -1535,7 +1535,9 @@ def handle_cloudconfig(cfg, base_dir=None):
# generate a path based on item key
# if path is already in the item, LOG warning, and use generated path
for cfgname, cfgvalue in cfg.items():
- cfgpath = "50-cloudconfig-%s.cfg" % cfgname
+ # cloud-init on debian-like distros includes a config '90_dpkg'.
+ # To ensure our config is applied afterward, we use a prefix > 90.
+ cfgpath = "95-cloudconfig-%s.cfg" % cfgname
if 'path' in cfgvalue:
LOG.warning("cloudconfig ignoring 'path' key in config")
cfgvalue['path'] = cfgpath
@@ -1785,30 +1787,23 @@ def builtin_curthooks(cfg, target, state):
description="setting up swap"):
add_swap(cfg, target, state.get('fstab'))
- if osfamily == DISTROS.suse:
- # set cloud-init maas datasource for SuSE images
+ if osfamily in {DISTROS.debian, DISTROS.suse, DISTROS.redhat}:
+ # set cloud-init maas datasource
if cfg.get('cloudconfig'):
handle_cloudconfig(
cfg['cloudconfig'],
base_dir=paths.target_path(target,
'etc/cloud/cloud.cfg.d'))
- if osfamily == DISTROS.redhat:
- # set cloud-init maas datasource for centos images
- if cfg.get('cloudconfig'):
- handle_cloudconfig(
- cfg['cloudconfig'],
- base_dir=paths.target_path(target,
- 'etc/cloud/cloud.cfg.d'))
-
- # For vmtests to force execute redhat_upgrade_cloud_init, uncomment
- # the value in examples/tests/centos_defaults.yaml
- if cfg.get('_ammend_centos_curthooks'):
- with events.ReportEventStack(
- name=stack_prefix + '/upgrading cloud-init',
- reporting_enabled=True, level="INFO",
- description="Upgrading cloud-init in target"):
- redhat_upgrade_cloud_init(cfg.get('network', {}), target)
+ if osfamily == DISTROS.redhat:
+ # For vmtests to force execute redhat_upgrade_cloud_init, uncomment
+ # the value in examples/tests/centos_defaults.yaml
+ if cfg.get('_ammend_centos_curthooks'):
+ with events.ReportEventStack(
+ name=stack_prefix + '/upgrading cloud-init',
+ reporting_enabled=True, level="INFO",
+ description="Upgrading cloud-init in target"):
+ redhat_upgrade_cloud_init(cfg.get('network', {}), target)
with events.ReportEventStack(
name=stack_prefix + '/apply-networking-config',
diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py
index d0243b3..558f79c 100644
--- a/tests/unittests/test_curthooks.py
+++ b/tests/unittests/test_curthooks.py
@@ -1371,10 +1371,10 @@ class TestUbuntuCoreHooks(CiTestCase):
expected_cfg = {
'file1': {
- 'path': '50-cloudconfig-file1.cfg',
+ 'path': '95-cloudconfig-file1.cfg',
'content': cloudconfig['file1']['content']},
'foobar': {
- 'path': '50-cloudconfig-foobar.cfg',
+ 'path': '95-cloudconfig-foobar.cfg',
'content': cloudconfig['foobar']['content']}
}
curthooks.handle_cloudconfig(cloudconfig, base_dir=cc_target)
Follow ups