* [PATCH 1/9] guestfs: base_image: fix custom-image include_tasks filename
2025-08-20 12:51 [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
@ 2025-08-20 12:51 ` Daniel Gomez
2025-08-20 12:51 ` [PATCH 2/9] guestfs: export kconfig yaml missing variables Daniel Gomez
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Daniel Gomez @ 2025-08-20 12:51 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
Ensure the custom-image.yml task is included when using custom OS image
path. Fixes typo.
Fixes: ad8cf5bbd636 ("Add a base-image role")
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
playbooks/roles/base_image/tasks/main.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/playbooks/roles/base_image/tasks/main.yml b/playbooks/roles/base_image/tasks/main.yml
index a708fd8d..37907d71 100644
--- a/playbooks/roles/base_image/tasks/main.yml
+++ b/playbooks/roles/base_image/tasks/main.yml
@@ -8,7 +8,7 @@
- name: Create custom upstream OS image
ansible.builtin.include_tasks:
- file: "{{ role_path }}/tasks/custom_image.yml"
+ file: "{{ role_path }}/tasks/custom-image.yml"
when:
- guestfs_has_custom_raw_image|bool
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/9] guestfs: export kconfig yaml missing variables
2025-08-20 12:51 [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
2025-08-20 12:51 ` [PATCH 1/9] guestfs: base_image: fix custom-image include_tasks filename Daniel Gomez
@ 2025-08-20 12:51 ` Daniel Gomez
2025-08-20 12:51 ` [PATCH 3/9] base_image: fix template dest fields in custom-image task Daniel Gomez
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Daniel Gomez @ 2025-08-20 12:51 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
Export to YAML the following kconfig variables as required by
custom-image task in the base_image role:
* GUESTFS_CUSTOM_RAW_IMAGE_SHA512SUMS_URL
* GUESTFS_CUSTOM_RAW_IMAGE_URL
* GUESTFS_HAS_CUSTOM_RAW_IMAGE
* GUESTFS_HAS_CUSTOM_RAW_IMAGE_ROLLING
* GUESTFS_HAS_CUSTOM_RAW_IMAGE_SHA512SUMS
* GUESTFS_HAS_CUSTOM_RAW_IMAGE_URL
Fixes: ad8cf5bbd636 ("Add a base-image role")
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
kconfigs/Kconfig.guestfs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kconfigs/Kconfig.guestfs b/kconfigs/Kconfig.guestfs
index ed08d293..a703ffe5 100644
--- a/kconfigs/Kconfig.guestfs
+++ b/kconfigs/Kconfig.guestfs
@@ -12,9 +12,11 @@ config GUESTFS_BASE_IMAGE_DIR
config GUESTFS_HAS_CUSTOM_RAW_IMAGE
bool
+ output yaml
config GUESTFS_HAS_CUSTOM_RAW_IMAGE_URL
bool
+ output yaml
config GUESTFS_REQUIRES_UEFI
bool
@@ -27,20 +29,24 @@ config GUESTFS_CUSTOM_RAW_IMAGE_URL
depends on GUESTFS_HAS_CUSTOM_RAW_IMAGE
depends on GUESTFS_HAS_CUSTOM_RAW_IMAGE_URL
string
+ output yaml
default "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-generic-amd64-daily.raw" if GUESTFS_DEBIAN_TRIXIE_GENERIC_AMD64
default "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-genericcloud-amd64-daily.raw" if GUESTFS_DEBIAN_TRIXIE_GENERIC_CLOUD_AMD64
default "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-nocloud-amd64-daily.raw" if GUESTFS_DEBIAN_TRIXIE_NOCLOUD_AMD64
config GUESTFS_HAS_CUSTOM_RAW_IMAGE_SHA512SUMS
bool
+ output yaml
config GUESTFS_CUSTOM_RAW_IMAGE_SHA512SUMS_URL
string
depends on GUESTFS_HAS_CUSTOM_RAW_IMAGE_SHA512SUMS
+ output yaml
default "https://cloud.debian.org/images/cloud/trixie/daily/latest/SHA512SUMS" if GUESTFS_DEBIAN_TRIXIE
config GUESTFS_HAS_CUSTOM_RAW_IMAGE_ROLLING
bool
+ output yaml
config GUESTFS_HAS_DISTRO_SOURCE_COPY_CAPABILITIES
bool
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 3/9] base_image: fix template dest fields in custom-image task
2025-08-20 12:51 [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
2025-08-20 12:51 ` [PATCH 1/9] guestfs: base_image: fix custom-image include_tasks filename Daniel Gomez
2025-08-20 12:51 ` [PATCH 2/9] guestfs: export kconfig yaml missing variables Daniel Gomez
@ 2025-08-20 12:51 ` Daniel Gomez
2025-08-20 13:29 ` Chuck Lever
2025-08-20 12:51 ` [PATCH 4/9] base_image: custom-image: fix variable scoping conflicts Daniel Gomez
` (6 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: Daniel Gomez @ 2025-08-20 12:51 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
The Ansible built-in template was using the wrong destiny module
parameter name. Fix the typo.
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html#parameter-dest
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
playbooks/roles/base_image/tasks/custom-image.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index ede44bd7..609dc515 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -102,7 +102,7 @@
- name: Build the custom source
ansible.builtin.template:
src: "{{ role_path }}/templates/custom-source.j2"
- dst: "{{ custom_source }}"
+ dest: "{{ custom_source }}"
mode: "u=rw,g=r,o=r"
when:
- not result.stat.exists
@@ -118,7 +118,7 @@
- name: Build the custom index
ansible.builtin.template:
src: "{{ role_path }}/templates/custom-index.j2"
- dst: "{{ custom_index }}"
+ dest: "{{ custom_index }}"
mode: "u=rw,g=r,o=r"
when:
- not result.stat.exists
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 3/9] base_image: fix template dest fields in custom-image task
2025-08-20 12:51 ` [PATCH 3/9] base_image: fix template dest fields in custom-image task Daniel Gomez
@ 2025-08-20 13:29 ` Chuck Lever
2025-08-21 8:22 ` Daniel Gomez
0 siblings, 1 reply; 13+ messages in thread
From: Chuck Lever @ 2025-08-20 13:29 UTC (permalink / raw)
To: Daniel Gomez, Luis Chamberlain; +Cc: kdevops, Daniel Gomez
On 8/20/25 8:51 AM, Daniel Gomez wrote:
> From: Daniel Gomez <da.gomez@samsung.com>
>
> The Ansible built-in template was using the wrong destiny module
s/destiny/destination
As I mentioned in the cover letter for the guestfs playbook series,
the "custom image" piece of that series was entirely untested, and the
category of fixes you've done in this series demonstrate that clearly.
Thank you for taking care of these!
For the series,
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
> parameter name. Fix the typo.
>
> https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html#parameter-dest
>
> Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
> ---
> playbooks/roles/base_image/tasks/custom-image.yml | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
> index ede44bd7..609dc515 100644
> --- a/playbooks/roles/base_image/tasks/custom-image.yml
> +++ b/playbooks/roles/base_image/tasks/custom-image.yml
> @@ -102,7 +102,7 @@
> - name: Build the custom source
> ansible.builtin.template:
> src: "{{ role_path }}/templates/custom-source.j2"
> - dst: "{{ custom_source }}"
> + dest: "{{ custom_source }}"
> mode: "u=rw,g=r,o=r"
> when:
> - not result.stat.exists
> @@ -118,7 +118,7 @@
> - name: Build the custom index
> ansible.builtin.template:
> src: "{{ role_path }}/templates/custom-index.j2"
> - dst: "{{ custom_index }}"
> + dest: "{{ custom_index }}"
> mode: "u=rw,g=r,o=r"
> when:
> - not result.stat.exists
>
--
Chuck Lever
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH 3/9] base_image: fix template dest fields in custom-image task
2025-08-20 13:29 ` Chuck Lever
@ 2025-08-21 8:22 ` Daniel Gomez
0 siblings, 0 replies; 13+ messages in thread
From: Daniel Gomez @ 2025-08-21 8:22 UTC (permalink / raw)
To: Chuck Lever, Luis Chamberlain; +Cc: kdevops, Daniel Gomez
On 20/08/2025 06.29, Chuck Lever wrote:
> On 8/20/25 8:51 AM, Daniel Gomez wrote:
>> From: Daniel Gomez <da.gomez@samsung.com>
>>
>> The Ansible built-in template was using the wrong destiny module
>
> s/destiny/destination
Fixed.
>
> As I mentioned in the cover letter for the guestfs playbook series,
> the "custom image" piece of that series was entirely untested, and the
> category of fixes you've done in this series demonstrate that clearly.
> Thank you for taking care of these!
No problem. It seems that the custom path is the only way forward with Debian.
FYI, the CI machine was using a previously generated custom Debian image. There
was no space left on the CI server, so the cleanup forced me to jump into these
fixes. :)
BTW, I have some changes ready for Debian Forky for whenever new images are
released.
https://github.com/dkruces/kdevops/tree/debian-forky
>
> For the series,
>
> Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Thanks! And pushed.
CI is working back again.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/9] base_image: custom-image: fix variable scoping conflicts
2025-08-20 12:51 [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
` (2 preceding siblings ...)
2025-08-20 12:51 ` [PATCH 3/9] base_image: fix template dest fields in custom-image task Daniel Gomez
@ 2025-08-20 12:51 ` Daniel Gomez
2025-08-20 12:51 ` [PATCH 5/9] guestfs: bringup: fix ssh key injection Daniel Gomez
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Daniel Gomez @ 2025-08-20 12:51 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
Replace all instances of 'register: result' with descriptive variable
names to prevent Ansible variable scoping conflicts that cause task
failures.
This prevents conditional logic from referencing wrong stat results and
eliminates race conditions in task execution.
Generated-by: Claude AI
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
playbooks/roles/base_image/tasks/custom-image.yml | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index 609dc515..6be012ec 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -31,7 +31,7 @@
get_attributes: false
get_checksum: false
get_mime: false
- register: result
+ register: custom_image_stat
- name: Fetch the custom image
ansible.builtin.get_url:
@@ -39,7 +39,7 @@
dest: "{{ custom_image_dir }}"
mode: "u=rw,g=r,o=r"
when:
- - not result.stat.exists
+ - not custom_image_stat.stat.exists
- guestfs_has_custom_raw_image_url|bool
- name: Check if the custom image sentinel file already exists
@@ -48,11 +48,11 @@
get_attributes: false
get_checksum: false
get_mime: false
- register: result
+ register: sentinel_stat
- name: Check the custom image
when:
- - not result.stat.exists
+ - not sentinel_stat.stat.exists
- guestfs_has_custom_raw_image_sha512sums|bool
block:
- name: Get the base name of the sha512sums file
@@ -69,7 +69,7 @@
get_attributes: false
get_checksum: false
get_mime: false
- register: result
+ register: sha512sums_stat
- name: Fetch the sha512sums file
ansible.builtin.get_url:
@@ -77,7 +77,7 @@
dest: "{{ custom_image_dir }}"
mode: "u=rw,g=r,o=r"
when:
- - not result.stat.exists
+ - not sha512sums_stat.stat.exists
- name: Compute checksum of something
ansible.builtin.command:
@@ -97,7 +97,7 @@
get_attributes: false
get_checksum: false
get_mime: false
- register: result
+ register: custom_source_stat
- name: Build the custom source
ansible.builtin.template:
@@ -105,7 +105,7 @@
dest: "{{ custom_source }}"
mode: "u=rw,g=r,o=r"
when:
- - not result.stat.exists
+ - not custom_source_stat.stat.exists
- name: Check if the custom index exists
ansible.builtin.stat:
@@ -113,7 +113,7 @@
get_attributes: false
get_checksum: false
get_mime: false
- register: result
+ register: custom_index_stat
- name: Build the custom index
ansible.builtin.template:
@@ -121,7 +121,7 @@
dest: "{{ custom_index }}"
mode: "u=rw,g=r,o=r"
when:
- - not result.stat.exists
+ - not custom_index_stat.stat.exists
- name: Show rolling distribution release warning
ansible.builtin.debug:
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 5/9] guestfs: bringup: fix ssh key injection
2025-08-20 12:51 [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
` (3 preceding siblings ...)
2025-08-20 12:51 ` [PATCH 4/9] base_image: custom-image: fix variable scoping conflicts Daniel Gomez
@ 2025-08-20 12:51 ` Daniel Gomez
2025-08-20 12:51 ` [PATCH 6/9] base_image: add become privileges for custom image setup Daniel Gomez
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Daniel Gomez @ 2025-08-20 12:51 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
This ensures the user exists before any SSH operations and uses
the standardized virt-builder.j2 template for consistent image
customization.
The custom-image role now:
* Detects the control host's kdevops UID and preserves it in guests
* Uses virt-builder.j2 template for all customization commands
* Handles both system and non-system libvirt configurations
* Creates temporary command files and cleans them up properly
Fixes error:
sudo virt-sysprep -a
/var/lib/libvirt/images/kdevops/guestfs/debian13/root.raw \
--hostname debian13 --ssh-inject \
kdevops:file:/media/tarkir/dagomez/src/linux-kdevops/
kdevops/guestfs/debian13/ssh/id_ed25519.pub \
--timezone Etc/UTC
[ 0.0] Examining the guest ...
[ 2.2] Performing "abrt-data" ...
[ 2.2] Performing "backup-files" ...
[ 2.3] Performing "bash-history" ...
...
[ 3.2] Performing "customize" ...
[ 3.2] Setting a random seed
virt-sysprep: warning: random seed could not be set for this type of
guest
[ 3.3] Setting the machine ID in /etc/machine-id
[ 3.3] Setting the hostname: debian13
[ 4.0] SSH key inject: kdevops
virt-sysprep: error: ssh-inject: the user kdevops does not exist on
the guest
If reporting bugs, run virt-sysprep with debugging enabled and include
the complete output:
virt-sysprep -v -x [...]
Generated-by: Claude AI
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
playbooks/roles/base_image/tasks/custom-image.yml | 72 +++++++++++++++++++++++
playbooks/roles/guestfs/tasks/main.yml | 12 ++++
2 files changed, 84 insertions(+)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index 6be012ec..329c437e 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -85,6 +85,78 @@
chdir: "{{ custom_image_dir }}"
changed_when: false
+ - name: Get the UID of the kdevops user on the control host
+ ansible.builtin.command:
+ cmd: "id -u kdevops"
+ register: id_output
+ changed_when: false
+ failed_when: false
+ when:
+ - not sentinel_stat.stat.exists
+
+ - name: Set the kdevops UID for custom image
+ ansible.builtin.set_fact:
+ kdevops_uid: "-u {{ id_output.stdout }}"
+ when:
+ - not sentinel_stat.stat.exists
+ - id_output.rc == 0
+
+ - name: Set default kdevops UID for custom image if user doesn't exist
+ ansible.builtin.set_fact:
+ kdevops_uid: ""
+ when:
+ - not sentinel_stat.stat.exists
+ - id_output.rc != 0
+
+ - name: Create a temporary file for virt-customize commands
+ ansible.builtin.tempfile:
+ state: file
+ register: custom_command_file
+ when:
+ - not sentinel_stat.stat.exists
+
+ - name: Construct the virt-customize command file for custom image
+ ansible.builtin.template:
+ src: "{{ role_path }}/templates/virt-builder.j2"
+ dest: "{{ custom_command_file.path }}"
+ mode: "u=rw"
+ when:
+ - not sentinel_stat.stat.exists
+
+ - name: Customize the downloaded image with kdevops user and settings
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.command:
+ argv:
+ - "virt-customize"
+ - "-a"
+ - "{{ custom_image }}"
+ - "--commands-from-file"
+ - "{{ custom_command_file.path }}"
+ when:
+ - libvirt_uri_system|bool
+ - not sentinel_stat.stat.exists
+
+ - name: Customize the downloaded image with kdevops user and settings (non-root)
+ ansible.builtin.command:
+ argv:
+ - "virt-customize"
+ - "-a"
+ - "{{ custom_image }}"
+ - "--commands-from-file"
+ - "{{ custom_command_file.path }}"
+ when:
+ - not libvirt_uri_system|bool
+ - not sentinel_stat.stat.exists
+
+ - name: Clean up the virt-customize command file
+ ansible.builtin.file:
+ path: "{{ custom_command_file.path }}"
+ state: absent
+ when:
+ - custom_command_file.path is defined
+ - not sentinel_stat.stat.exists
+
- name: Touch the custom image sentinel
ansible.builtin.file:
path: "{{ custom_image_ok }}"
diff --git a/playbooks/roles/guestfs/tasks/main.yml b/playbooks/roles/guestfs/tasks/main.yml
index 644922b9..2ec44204 100644
--- a/playbooks/roles/guestfs/tasks/main.yml
+++ b/playbooks/roles/guestfs/tasks/main.yml
@@ -31,6 +31,18 @@
- bringup
ansible.builtin.set_fact:
base_image: "{{ storagedir }}/base_images/{{ virtbuilder_os_version }}.raw"
+ when:
+ - not guestfs_has_custom_raw_image|bool
+ delegate_to: localhost
+
+- name: Set the pathname of the custom OS base image
+ tags:
+ - base_image
+ - bringup
+ ansible.builtin.set_fact:
+ base_image: "{{ storagedir }}/custom_images/{{ virtbuilder_os_version }}/{{ virtbuilder_os_version }}.raw"
+ when:
+ - guestfs_has_custom_raw_image|bool
delegate_to: localhost
- name: Ensure the required base OS image exists
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 6/9] base_image: add become privileges for custom image setup
2025-08-20 12:51 [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
` (4 preceding siblings ...)
2025-08-20 12:51 ` [PATCH 5/9] guestfs: bringup: fix ssh key injection Daniel Gomez
@ 2025-08-20 12:51 ` Daniel Gomez
2025-08-20 12:51 ` [PATCH 7/9] guestfs: debian: ensure dhcpcd-base runtime dependency Daniel Gomez
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Daniel Gomez @ 2025-08-20 12:51 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
Add proper privilege escalation to tasks requiring elevated privileges
in CI and system environments.
Privilege patterns:
- become: true alone - System paths (/etc/, /var/lib/libvirt/) that always need root
- become: true + become_method: sudo - File operations, image tools needing explicit sudo
- Conditional become - VM operations where privilege depends on libvirt URI:
* qemu:///system (root daemon): requires sudo
* qemu:///session (user daemon): runs with user permissions
This ensures custom image setup works across both system-level and
user-level libvirt configurations.
Generated-by: Claude AI
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
playbooks/roles/base_image/tasks/custom-image.yml | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index 329c437e..e5bf3699 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -4,6 +4,7 @@
custom_image_dir: "{{ kdevops_storage_pool_path }}/guestfs/custom_images/{{ base_image_os_version }}"
- name: Ensure the custom image directory exists
+ become: true
ansible.builtin.file:
path: "{{ custom_image_dir }}"
state: directory
@@ -34,6 +35,8 @@
register: custom_image_stat
- name: Fetch the custom image
+ become: true
+ become_method: ansible.builtin.sudo
ansible.builtin.get_url:
url: "{{ guestfs_custom_raw_image_url }}"
dest: "{{ custom_image_dir }}"
@@ -72,6 +75,8 @@
register: sha512sums_stat
- name: Fetch the sha512sums file
+ become: true
+ become_method: ansible.builtin.sudo
ansible.builtin.get_url:
url: "{{ guestfs_custom_raw_image_sha512sums_url }}"
dest: "{{ custom_image_dir }}"
@@ -158,6 +163,8 @@
- not sentinel_stat.stat.exists
- name: Touch the custom image sentinel
+ become: true
+ become_method: ansible.builtin.sudo
ansible.builtin.file:
path: "{{ custom_image_ok }}"
state: touch
@@ -172,6 +179,7 @@
register: custom_source_stat
- name: Build the custom source
+ become: true
ansible.builtin.template:
src: "{{ role_path }}/templates/custom-source.j2"
dest: "{{ custom_source }}"
@@ -188,6 +196,8 @@
register: custom_index_stat
- name: Build the custom index
+ become: true
+ become_method: ansible.builtin.sudo
ansible.builtin.template:
src: "{{ role_path }}/templates/custom-index.j2"
dest: "{{ custom_index }}"
@@ -223,6 +233,8 @@
Custom virt-builder image: {{ custom_image }}
- name: Generating the index for {{ base_image_os_version }}
+ become: true
+ become_method: ansible.builtin.sudo
ansible.builtin.command:
argv:
- "virt-builder-repository"
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 7/9] guestfs: debian: ensure dhcpcd-base runtime dependency
2025-08-20 12:51 [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
` (5 preceding siblings ...)
2025-08-20 12:51 ` [PATCH 6/9] base_image: add become privileges for custom image setup Daniel Gomez
@ 2025-08-20 12:51 ` Daniel Gomez
2025-08-20 12:51 ` [PATCH 8/9] guestfs: add unified LIBVIRT_IMAGE_SIZE configuration Daniel Gomez
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Daniel Gomez @ 2025-08-20 12:51 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
After updating kdevops CI Debian testing server from Debian trixie
-> forky, virt-builder was unable (again) to bring up a guest with
network capabilities.
When libguestfs-tools are installed, we need to ensure both
isc-dhcp-client and dhcpcd-base packages are installed as explained in
commit 53d1d15b0792 ("guestfs: bringup: fix debian networking issue").
This ensures both packages are installed, allowing virt-builder to find
the right tools in both Debian distros.
Generated-by: Claude AI
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
playbooks/roles/guestfs/tasks/install-deps/debian/main.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/playbooks/roles/guestfs/tasks/install-deps/debian/main.yml b/playbooks/roles/guestfs/tasks/install-deps/debian/main.yml
index 1626e75a..c4575afe 100644
--- a/playbooks/roles/guestfs/tasks/install-deps/debian/main.yml
+++ b/playbooks/roles/guestfs/tasks/install-deps/debian/main.yml
@@ -14,6 +14,7 @@
update_cache: true
name:
- libguestfs-tools
+ - dhcpcd-base
- isc-dhcp-client
- python3-lxml
- python3-libvirt
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 8/9] guestfs: add unified LIBVIRT_IMAGE_SIZE configuration
2025-08-20 12:51 [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
` (6 preceding siblings ...)
2025-08-20 12:51 ` [PATCH 7/9] guestfs: debian: ensure dhcpcd-base runtime dependency Daniel Gomez
@ 2025-08-20 12:51 ` Daniel Gomez
2025-08-20 12:51 ` [PATCH 9/9] guestfs: fix locale warnings in VM deployments Daniel Gomez
2025-08-21 7:26 ` [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
9 siblings, 0 replies; 13+ messages in thread
From: Daniel Gomez @ 2025-08-20 12:51 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
Add configurable VM base image size to prevent disk space issues.
Previously custom image path was stuck at small download sizes while
base images used configurable size.
Changes:
- Add LIBVIRT_IMAGE_SIZE configuration in Kconfig.libvirt with "20G" default
- Update base-image.yml to use libvirt_image_size variable
- Add qemu-img resize for downloaded custom images to respect size config
This ensures both base images (virt-builder) and custom images
(downloaded and resized) use consistent disk sizing configuration.
Generated-by: Claude AI
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
kconfigs/Kconfig.libvirt | 10 ++++++++++
playbooks/roles/base_image/tasks/base-image.yml | 4 ++--
playbooks/roles/base_image/tasks/custom-image.yml | 11 +++++++++++
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/kconfigs/Kconfig.libvirt b/kconfigs/Kconfig.libvirt
index 61502c17..7fe23166 100644
--- a/kconfigs/Kconfig.libvirt
+++ b/kconfigs/Kconfig.libvirt
@@ -458,6 +458,16 @@ config LIBVIRT_MEM_MB
help
How much MiB of RAM to use per guest.
+config LIBVIRT_IMAGE_SIZE
+ string "VM image size"
+ output yaml
+ default "20G"
+ depends on GUESTFS
+ help
+ The size of the VM disk image for all libvirt images, whether they
+ are base images (created with virt-builder) or custom images
+ (downloaded and resized with qemu-img resize).
+
config HAVE_LIBVIRT_PCIE_PASSTHROUGH
bool
default $(shell, scripts/check_pciepassthrough_kconfig.sh passthrough_libvirt.generated)
diff --git a/playbooks/roles/base_image/tasks/base-image.yml b/playbooks/roles/base_image/tasks/base-image.yml
index 84971b61..d1f99a77 100644
--- a/playbooks/roles/base_image/tasks/base-image.yml
+++ b/playbooks/roles/base_image/tasks/base-image.yml
@@ -44,7 +44,7 @@
- "-o"
- "{{ base_image_pathname }}"
- "--size"
- - "20G"
+ - "{{ libvirt_image_size }}"
- "--format"
- "raw"
- "--commands-from-file"
@@ -63,7 +63,7 @@
- "-o"
- "{{ base_image_pathname }}"
- "--size"
- - "20G"
+ - "{{ libvirt_image_size }}"
- "--format"
- "raw"
- "--commands-from-file"
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index e5bf3699..46701e75 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -41,10 +41,21 @@
url: "{{ guestfs_custom_raw_image_url }}"
dest: "{{ custom_image_dir }}"
mode: "u=rw,g=r,o=r"
+ register: custom_image_download
when:
- not custom_image_stat.stat.exists
- guestfs_has_custom_raw_image_url|bool
+- name: Resize custom image to match configured size
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.command:
+ cmd: "qemu-img resize {{ custom_image }} {{ libvirt_image_size }}"
+ changed_when: true
+ when:
+ - custom_image_download is changed or custom_image_stat.stat.exists
+ - guestfs_has_custom_raw_image_url|bool
+
- name: Check if the custom image sentinel file already exists
ansible.builtin.stat:
path: "{{ custom_image_ok }}"
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 9/9] guestfs: fix locale warnings in VM deployments
2025-08-20 12:51 [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
` (7 preceding siblings ...)
2025-08-20 12:51 ` [PATCH 8/9] guestfs: add unified LIBVIRT_IMAGE_SIZE configuration Daniel Gomez
@ 2025-08-20 12:51 ` Daniel Gomez
2025-08-21 7:26 ` [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
9 siblings, 0 replies; 13+ messages in thread
From: Daniel Gomez @ 2025-08-20 12:51 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
Fix "cannot change locale" SSH warnings by configuring locales
comprehensively across both new and existing VM deployments.
New VMs (virt-builder template):
- Add locales-all package for comprehensive locale support
- Configure en_US.UTF-8 during both image build and first boot
- Remove problematic dpkg-reconfigure command
Existing VMs (devconfig tasks):
- Install locales-all package if missing
- Configure /etc/default/locale and /etc/locale.gen files
- Generate and update locales with locale-gen and update-locale
This ensures en_US.UTF-8 locale is available at boot, eliminating
SSH warnings across all VM deployment scenarios.
Generated-by: Claude AI
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
.../roles/base_image/templates/virt-builder.j2 | 5 +--
playbooks/roles/devconfig/tasks/main.yml | 42 ++++++++++++++++++++++
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/playbooks/roles/base_image/templates/virt-builder.j2 b/playbooks/roles/base_image/templates/virt-builder.j2
index 6abb7e66..7df42294 100644
--- a/playbooks/roles/base_image/templates/virt-builder.j2
+++ b/playbooks/roles/base_image/templates/virt-builder.j2
@@ -11,7 +11,7 @@ mkdir {{ target_dir }}
copy-in {{ guestfs_distro_source_and_dest_file }}:{{ target_dir }}
{% endif %}
-install sudo,qemu-guest-agent,python3,bash
+install sudo,qemu-guest-agent,python3,bash,locales-all
run-command useradd {{ kdevops_uid }} -s /bin/bash -m kdevops
append-line /etc/sudoers.d/kdevops:kdevops ALL=(ALL) NOPASSWD: ALL
edit /etc/default/grub:s/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"/
@@ -63,9 +63,10 @@ uninstall cloud-init
write /etc/default/locale:LANG=en_US.UTF-8
append-line /etc/default/locale:LANGUAGE=en_US:en
write /etc/locale.gen:en_US.UTF-8 UTF-8
+run-command locale-gen en_US.UTF-8
+run-command update-locale LANG=en_US.UTF-8
firstboot-command locale-gen en_US.UTF-8
firstboot-command update-locale LANG=en_US.UTF-8
-firstboot-command DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true dpkg-reconfigure -p low --force locales
firstboot-command systemctl stop ssh
firstboot-command systemctl start ssh
diff --git a/playbooks/roles/devconfig/tasks/main.yml b/playbooks/roles/devconfig/tasks/main.yml
index ceb0f2e8..c7bb5352 100644
--- a/playbooks/roles/devconfig/tasks/main.yml
+++ b/playbooks/roles/devconfig/tasks/main.yml
@@ -29,6 +29,48 @@
dest: /etc/hostname
tags: hostname
+- name: Ensure locales-all package is installed
+ become: true
+ become_flags: 'su - -c'
+ become_method: sudo
+ ansible.builtin.package:
+ name: locales-all
+ state: present
+ when:
+ - ansible_facts['os_family']|lower == 'debian'
+ tags: firstconfig
+
+- name: Configure en_US.UTF-8 locale files
+ become: true
+ become_flags: 'su - -c'
+ become_method: sudo
+ ansible.builtin.lineinfile:
+ path: "{{ item.path }}"
+ line: "{{ item.line }}"
+ create: true
+ mode: '0644'
+ owner: root
+ group: root
+ loop:
+ - { path: '/etc/default/locale', line: 'LANG=en_US.UTF-8' }
+ - { path: '/etc/default/locale', line: 'LANGUAGE=en_US:en' }
+ - { path: '/etc/locale.gen', line: 'en_US.UTF-8 UTF-8' }
+ when:
+ - ansible_facts['os_family']|lower == 'debian'
+ tags: firstconfig
+
+- name: Generate and update locales
+ become: true
+ become_flags: 'su - -c'
+ become_method: sudo
+ ansible.builtin.shell: |
+ locale-gen en_US.UTF-8
+ update-locale LANG=en_US.UTF-8
+ changed_when: true
+ when:
+ - ansible_facts['os_family']|lower == 'debian'
+ tags: firstconfig
+
# Distro specific
# Check and fix APT mirrors for Debian testing before installing dependencies
--
2.50.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 0/9] Fix guestfs custom-image path
2025-08-20 12:51 [PATCH 0/9] Fix guestfs custom-image path Daniel Gomez
` (8 preceding siblings ...)
2025-08-20 12:51 ` [PATCH 9/9] guestfs: fix locale warnings in VM deployments Daniel Gomez
@ 2025-08-21 7:26 ` Daniel Gomez
9 siblings, 0 replies; 13+ messages in thread
From: Daniel Gomez @ 2025-08-21 7:26 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever, Daniel Gomez; +Cc: kdevops
On Wed, 20 Aug 2025 14:51:34 +0200, Daniel Gomez wrote:
> After upgrading CI host to Debian forky, multiple guestfs custom image
> path issues were found. This series fixes VM bringup problems affecting
> Debian guests.
>
> Core Issues Fixed:
> - Custom image path stuck at small download sizes (no resize support)
> - Locale warnings during SSH connections ("cannot change locale")
> - Missing dhcpcd-base dependency breaking VM networking
> - Permission errors in CI environments for custom image setup
> - SSH key injection failing due to missing kdevops user
> - Variable scoping conflicts causing task failures
> - Missing Kconfig YAML exports preventing custom image workflow
>
> [...]
Applied, thanks!
[1/9] guestfs: base_image: fix custom-image include_tasks filename
commit: b9288ee7c3477a2c8d9ec2835c983bd8c033a9d8
[2/9] guestfs: export kconfig yaml missing variables
commit: e7fb52fd373983732fe1c363859ae73300d00bb8
[3/9] base_image: fix template dest fields in custom-image task
commit: 114b0255ef3246a754a6d4ac7d75ff2b89d29469
[4/9] base_image: custom-image: fix variable scoping conflicts
commit: 1c5fdc281728b7a0fb1d07c95f5d07ad10879c1c
[5/9] guestfs: bringup: fix ssh key injection
commit: 7af0e602e8c8c5e05d5be90c0341a0652ad03e91
[6/9] base_image: add become privileges for custom image setup
commit: 02b967b6806a506d3448fbafc4360978ac6c96a1
[7/9] guestfs: debian: ensure dhcpcd-base runtime dependency
commit: 377bbf2c7ef794eb09df028312a9fadb9d4ad228
[8/9] guestfs: add unified LIBVIRT_IMAGE_SIZE configuration
commit: e46bf3cd54de8b4592f755b4fd2d320be9ec6ba7
[9/9] guestfs: fix locale warnings in VM deployments
commit: 2514a69443fcad514e63e2aada2f4a1bcc965415
Best regards,
--
Daniel Gomez <da.gomez@samsung.com>
^ permalink raw reply [flat|nested] 13+ messages in thread