[PATCH 1/5] base_image: fix missing guestfs_distro_source_and_dest_file in yaml output

Daniel Gomez <[email protected]>
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
From: Daniel Gomez <[email protected]>

The GUESTFS_DISTRO_SOURCE_AND_DEST_FILE kconfig variable was missing
the "output yaml" directive, causing it to be defined in .config but
not exported to extra_vars.yaml that Ansible actually consumes.

This resulted in the variable being undefined in Ansible templates:
  jinja2.exceptions.UndefinedError: 'target_dir' is undefined
  TypeError: expected str, bytes or os.PathLike object, not AnsibleUndefined

The issue only manifested on some machines due to different Ansible
execution contexts - the variable was in .config but missing from
extra_vars.yaml where templates expect it.

Fixed by adding "output yaml" to GUESTFS_DISTRO_SOURCE_AND_DEST_FILE
kconfig definition, ensuring proper variable export to Ansible.

Generated-by: Claude AI
Signed-off-by: Daniel Gomez <[email protected]>
---
 kconfigs/Kconfig.guestfs                             | 1 +
 playbooks/roles/base_image/templates/virt-builder.j2 | 1 +
 2 files changed, 2 insertions(+)

diff --git a/kconfigs/Kconfig.guestfs b/kconfigs/Kconfig.guestfs
index a703ffe5..d1e922a6 100644
--- a/kconfigs/Kconfig.guestfs
+++ b/kconfigs/Kconfig.guestfs
@@ -60,6 +60,7 @@ config GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST
 config GUESTFS_DISTRO_SOURCE_AND_DEST_FILE
 	string
 	depends on GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST
+	output yaml
 	default "/etc/apt/sources.list" if GUESTFS_DEBIAN
 
 endif
diff --git a/playbooks/roles/base_image/templates/virt-builder.j2 b/playbooks/roles/base_image/templates/virt-builder.j2
index 138d06ee..6805679a 100644
--- a/playbooks/roles/base_image/templates/virt-builder.j2
+++ b/playbooks/roles/base_image/templates/virt-builder.j2
@@ -7,6 +7,7 @@ copy-in {{ kdevops_custom_yum_repofile }}:/etc/yum.repos.d
 {% endif %}
 
 {% if guestfs_copy_sources_from_host_to_guest %}
+{% set target_dir = guestfs_distro_source_and_dest_file | dirname %}
 mkdir {{ target_dir }}
 copy-in {{ guestfs_distro_source_and_dest_file }}:{{ target_dir }}
 {% endif %}

-- 
2.50.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.