canonical / canonical/cloud-init

uses_systemd in cloudinit.distros doesn't properly detect systemd if VM isn't running

Open
#5,518 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

# Bug report
https://github.com/canonical/cloud-init/blob/e0e6a427fdc6826bf7b11d52157a1c5f9b3dde4d/cloudinit/distros/__init__.py#L1608-L1613 returns a "*false* `False`" if the the target VM is being edited using offline tools (e.g. libguestfs), since `/run` is only populated on a running system

## Steps to reproduce the problem
`virt-customize -a .qcow2 --run-command 'cloud-init clean --machine-id'` should produce an `/etc/machine-id` of `undefined`; instead it deletes the file entirely (the non-systemd result)

## Environment details
- Cloud-init version: 24.2
- Operating System Distribution: Debian 12
- Cloud provider, platform or installer type: `virt-customize`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.