* [PATCH] guestfs: port status script to Ansible with libvirt URI fix
@ 2025-09-17 8:49 Daniel Gomez
2025-09-17 13:45 ` Chuck Lever
2025-09-17 14:28 ` Luis Chamberlain
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Gomez @ 2025-09-17 8:49 UTC (permalink / raw)
To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez
From: Daniel Gomez <da.gomez@samsung.com>
Convert scripts/status_guestfs.sh shell script to Ansible implementation
in playbooks/roles/guestfs/tasks/status/main.yml. The new implementation:
- Uses proper libvirt_uri variable for LIBVIRT_DEFAULT_URI
- Integrates with DIY callback to show command output
- Provides idempotent Ansible approach with tagging support
- Fixes missing libvirt URI context that caused empty virsh output
Update scripts/guestfs.Makefile to call ansible-playbook with --tags status
instead of the shell script. Add missing output yaml to LIBVIRT_URI_PATH
for proper URI variable generation.
Generated-by: Claude AI
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
The conversion in combination with the DIY stdout callback support [1]
results in this nice human readable output:
Link: https://lore.kernel.org/kdevops/aMnm2GQ0hdxNgYGd@bombadil.infradead.org/ [1]
make status
PLAY: MANAGE INFRASTRUCTURE LIFECYCLE AND SSH ACCESS WITH LIBVIRT/GUESTFS
TASK: Gathering Facts
start: [localhost]
start: [debian13-xarray]
ok: [localhost]
ok: [debian13-xarray]
TASK: Display VM status
start: [localhost]
Id Name State
---------------------------------
9 debian13-xarray running
PLAYBOOK SUMMARY
================
STATUS OK CHANGED FAILED HOST
OK 1 0 0 debian13-xarray
OK 2 0 0 localhost
I think DIY should be the default stdout callback for kdevops. This
example is meant to encourage users to try it out, and if the feedback
is positive, we can move forward with a formal proposal (there's no
rush).
---
kconfigs/Kconfig.libvirt | 1 +
playbooks/roles/guestfs/tasks/main.yml | 7 +++++++
playbooks/roles/guestfs/tasks/status/main.yml | 9 +++++++++
scripts/guestfs.Makefile | 5 ++++-
scripts/status_guestfs.sh | 5 -----
5 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/kconfigs/Kconfig.libvirt b/kconfigs/Kconfig.libvirt
index 25cb703f..af34a33c 100644
--- a/kconfigs/Kconfig.libvirt
+++ b/kconfigs/Kconfig.libvirt
@@ -118,6 +118,7 @@ endchoice
config LIBVIRT_URI_PATH
string "Libvirt QEMU URI to use"
+ output yaml
default "qemu:///system" if LIBVIRT_URI_SYSTEM || LIBVIRT_URI_CUSTOM
default "qemu:///session" if LIBVIRT_URI_SESSION
help
diff --git a/playbooks/roles/guestfs/tasks/main.yml b/playbooks/roles/guestfs/tasks/main.yml
index 2ec44204..6618687e 100644
--- a/playbooks/roles/guestfs/tasks/main.yml
+++ b/playbooks/roles/guestfs/tasks/main.yml
@@ -77,3 +77,10 @@
ansible.builtin.import_tasks:
file: "{{ role_path }}/tasks/destroy.yml"
delegate_to: localhost
+
+- name: Status VM tasks
+ tags:
+ - status
+ ansible.builtin.import_tasks:
+ file: "{{ role_path }}/tasks/status/main.yml"
+ delegate_to: localhost
diff --git a/playbooks/roles/guestfs/tasks/status/main.yml b/playbooks/roles/guestfs/tasks/status/main.yml
new file mode 100644
index 00000000..ad1e0348
--- /dev/null
+++ b/playbooks/roles/guestfs/tasks/status/main.yml
@@ -0,0 +1,9 @@
+---
+- name: Display VM status
+ ansible.builtin.shell: |
+ LIBVIRT_DEFAULT_URI="{{ libvirt_uri }}" virsh list --all
+ changed_when: false
+ delegate_to: localhost
+ run_once: true
+ vars:
+ ansible_callback_diy_runner_on_ok_msg: "{{ ansible_callback_diy.result.output.stdout }}"
diff --git a/scripts/guestfs.Makefile b/scripts/guestfs.Makefile
index 953c6149..68aa282f 100644
--- a/scripts/guestfs.Makefile
+++ b/scripts/guestfs.Makefile
@@ -91,7 +91,10 @@ bringup_guestfs: $(GUESTFS_BRINGUP_DEPS)
PHONY += bringup_guestfs
status_guestfs:
- $(Q)scripts/status_guestfs.sh
+ $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
+ playbooks/guestfs.yml \
+ --extra-vars=@./extra_vars.yaml \
+ --tags status
PHONY += status_guestfs
destroy_guestfs:
diff --git a/scripts/status_guestfs.sh b/scripts/status_guestfs.sh
deleted file mode 100755
index 84cb26cf..00000000
--- a/scripts/status_guestfs.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: copyleft-next-0.3.1
-
-virsh list
-exit 0
---
base-commit: 4deb164b5926aaef3f864f3a49358ec6c1da8238
change-id: 20250917-status-script-e22d4ac7b009
Best regards,
--
Daniel Gomez <da.gomez@samsung.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] guestfs: port status script to Ansible with libvirt URI fix
2025-09-17 8:49 [PATCH] guestfs: port status script to Ansible with libvirt URI fix Daniel Gomez
@ 2025-09-17 13:45 ` Chuck Lever
2025-09-17 14:28 ` Luis Chamberlain
1 sibling, 0 replies; 3+ messages in thread
From: Chuck Lever @ 2025-09-17 13:45 UTC (permalink / raw)
To: Daniel Gomez, Luis Chamberlain; +Cc: kdevops, Daniel Gomez
On 9/17/25 1:49 AM, Daniel Gomez wrote:
> From: Daniel Gomez <da.gomez@samsung.com>
>
> Convert scripts/status_guestfs.sh shell script to Ansible implementation
> in playbooks/roles/guestfs/tasks/status/main.yml. The new implementation:
>
> - Uses proper libvirt_uri variable for LIBVIRT_DEFAULT_URI
> - Integrates with DIY callback to show command output
> - Provides idempotent Ansible approach with tagging support
> - Fixes missing libvirt URI context that caused empty virsh output
>
> Update scripts/guestfs.Makefile to call ansible-playbook with --tags status
> instead of the shell script. Add missing output yaml to LIBVIRT_URI_PATH
> for proper URI variable generation.
>
> Generated-by: Claude AI
> Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
I hadn't done this already because the Ansible implementation of these
steps takes noticeably more time. But I don't mind that if you guys
don't.
--
Chuck Lever
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] guestfs: port status script to Ansible with libvirt URI fix
2025-09-17 8:49 [PATCH] guestfs: port status script to Ansible with libvirt URI fix Daniel Gomez
2025-09-17 13:45 ` Chuck Lever
@ 2025-09-17 14:28 ` Luis Chamberlain
1 sibling, 0 replies; 3+ messages in thread
From: Luis Chamberlain @ 2025-09-17 14:28 UTC (permalink / raw)
To: Daniel Gomez; +Cc: Chuck Lever, kdevops, Daniel Gomez
On Wed, Sep 17, 2025 at 10:49:31AM +0200, Daniel Gomez wrote:
> From: Daniel Gomez <da.gomez@samsung.com>
>
> Convert scripts/status_guestfs.sh shell script to Ansible implementation
> in playbooks/roles/guestfs/tasks/status/main.yml. The new implementation:
>
> - Uses proper libvirt_uri variable for LIBVIRT_DEFAULT_URI
> - Integrates with DIY callback to show command output
> - Provides idempotent Ansible approach with tagging support
> - Fixes missing libvirt URI context that caused empty virsh output
>
> Update scripts/guestfs.Makefile to call ansible-playbook with --tags status
> instead of the shell script. Add missing output yaml to LIBVIRT_URI_PATH
> for proper URI variable generation.
>
> Generated-by: Claude AI
> Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
Thanks! Applied and pushed!
Luis
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-17 14:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 8:49 [PATCH] guestfs: port status script to Ansible with libvirt URI fix Daniel Gomez
2025-09-17 13:45 ` Chuck Lever
2025-09-17 14:28 ` Luis Chamberlain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox