Jacopo Rota has proposed merging ~r00ta/curtin:maas-debian-cloudconfig into curtin:master.
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/486221 As of now, cloud-init on debian distros needs dkpg-reconfigure. However, they would like MAAS to configure cloud-init in another alternative way so that they can remove that custom logic. This MP aims to use cloudconfig also for debian distros when configuring cloud-init. We still need to keep the dpkg-reconfigure logic as we have to deployments up to trusty that need the old dpkg-reconfigure logic. -- Your team curtin developers is requested to review the proposed merge of ~r00ta/curtin:maas-debian-cloudconfig into curtin:master.
diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py index 2d024f0..1a5e5c9 100644 --- a/curtin/commands/apt_config.py +++ b/curtin/commands/apt_config.py @@ -1075,6 +1075,7 @@ def POPULATE_SUBCMD(parser): CONFIG_CLEANERS = { + # Always reconfigure cloud-init even if from 25.10 MAAS uses cloudconfig. 'cloud-init': clean_cloud_init, 'cloud-init-base': clean_cloud_init, } diff --git a/curtin/commands/curthooks.py b/curtin/commands/curthooks.py index b54e3c9..41302db 100644 --- a/curtin/commands/curthooks.py +++ b/curtin/commands/curthooks.py @@ -1689,7 +1689,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 @@ -1963,21 +1965,23 @@ def builtin_curthooks(cfg: dict, target: str, state: dict): 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')) + 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) # For vmtests to force execute redhat_upgrade_cloud_init, uncomment # the value in examples/tests/centos_defaults.yaml diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py index f8344d4..0dcab1f 100644 --- a/tests/unittests/test_curthooks.py +++ b/tests/unittests/test_curthooks.py @@ -1589,10 +1589,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)
-- Mailing list: https://launchpad.net/~curtin-dev Post to : curtin-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~curtin-dev More help : https://help.launchpad.net/ListHelp