Skip to content

Commit 3f80191

Browse files
dkrucesmcgrof
authored andcommitted
guestfs: port status script to Ansible with libvirt URI fix
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 <[email protected]> Reviewed-by: Chuck Lever <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent d7028bd commit 3f80191

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

kconfigs/Kconfig.libvirt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ endchoice
118118

119119
config LIBVIRT_URI_PATH
120120
string "Libvirt QEMU URI to use"
121+
output yaml
121122
default "qemu:///system" if LIBVIRT_URI_SYSTEM || LIBVIRT_URI_CUSTOM
122123
default "qemu:///session" if LIBVIRT_URI_SESSION
123124
help

playbooks/roles/guestfs/tasks/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,10 @@
7777
ansible.builtin.import_tasks:
7878
file: "{{ role_path }}/tasks/destroy.yml"
7979
delegate_to: localhost
80+
81+
- name: Status VM tasks
82+
tags:
83+
- status
84+
ansible.builtin.import_tasks:
85+
file: "{{ role_path }}/tasks/status/main.yml"
86+
delegate_to: localhost
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Display VM status
3+
ansible.builtin.shell: |
4+
LIBVIRT_DEFAULT_URI="{{ libvirt_uri }}" virsh list --all
5+
changed_when: false
6+
delegate_to: localhost
7+
run_once: true
8+
vars:
9+
ansible_callback_diy_runner_on_ok_msg: "{{ ansible_callback_diy.result.output.stdout }}"

scripts/guestfs.Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ bringup_guestfs: $(GUESTFS_BRINGUP_DEPS)
9191
PHONY += bringup_guestfs
9292

9393
status_guestfs:
94-
$(Q)scripts/status_guestfs.sh
94+
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
95+
playbooks/guestfs.yml \
96+
--extra-vars=@./extra_vars.yaml \
97+
--tags status
9598
PHONY += status_guestfs
9699

97100
destroy_guestfs:

scripts/status_guestfs.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)