Skip to content

Commit f17767a

Browse files
committed
Fix wizard disabling on headless images
Signed-off-by: paulober <paul.oberosler@raspberrypi.com>
1 parent c32d457 commit f17767a

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

cloudinit/distros/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Copyright (C) 2012 Canonical Ltd.
22
# Copyright (C) 2012, 2013 Hewlett-Packard Development Company, L.P.
33
# Copyright (C) 2012 Yahoo! Inc.
4+
# Copyright (C) 2025 Raspberry Pi Ltd.
45
#
56
# Author: Scott Moser <scott.moser@canonical.com>
67
# Author: Juerg Haefliger <juerg.haefliger@hp.com>
78
# Author: Joshua Harlow <harlowja@yahoo-inc.com>
89
# Author: Ben Howard <ben.howard@canonical.com>
10+
# Author: Paul Oberosler <paul.oberosler@raspberrypi.com>
911
#
1012
# This file is part of cloud-init. See LICENSE file for license information.
1113

@@ -1367,6 +1369,8 @@ def manage_service(
13671369
"reload": ["reload-or-restart", service],
13681370
"try-reload": ["try-reload-or-restart", service],
13691371
"status": ["status", service],
1372+
"mask": ["mask", service],
1373+
"unmask": ["unmask", service],
13701374
}
13711375
else:
13721376
cmds = {
@@ -1378,6 +1382,8 @@ def manage_service(
13781382
"reload": [service, "restart"],
13791383
"try-reload": [service, "restart"],
13801384
"status": [service, "status"],
1385+
"mask": [service, "stop"],
1386+
"unmask": [service, "stop"],
13811387
}
13821388
cmd = init_cmd + cmds[action] + list(extra_args)
13831389
return subp.subp(cmd, capture=True, rcs=rcs)

cloudinit/distros/raspberry_pi_os.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ def add_user(self, name, **kwargs) -> bool:
8383
if plain:
8484
self.set_passwd(name, plain, hashed=False)
8585

86+
# Mask userconfig.service
87+
self.manage_service("mask", "userconfig.service", "--now")
88+
8689
# honor all other options that would otherwise
8790
# add_user have taken care of
8891

tests/unittests/distros/test_raspberry_pi_os.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ def test_add_user_happy_path(self, m_subp):
6363
cls = fetch("raspberry_pi_os")
6464
distro = cls("raspberry-pi-os", {}, None)
6565

66-
assert distro.add_user("pi") is True
66+
with mock.patch(
67+
"cloudinit.distros.Distro.manage_service", return_value=True
68+
) as m_service:
69+
assert distro.add_user("pi") is True
6770
m_subp.assert_called_once()
6871

6972
# Accept both common locations for userconf

0 commit comments

Comments
 (0)