diff mbox series

[07/12] ansible: Run sudo by using the '-K' ansible arg

Message ID 20241218-jag-bringup_fixes-v1-7-0bf2e07c640c@kernel.org (mailing list archive)
State New
Headers show
Series kdevops: Various fixes | expand

Commit Message

Joel Granados Dec. 18, 2024, 10:30 a.m. UTC
This patch does two things:
* Remove the become_flags from sudo tasks in bringup_guestfs and
  libvirt_user roles
* Call the playbook with the -K argument so the user enters the
  sudo password just once after the playbook call

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
 playbooks/roles/bringup_guestfs/tasks/main.yml                 | 6 ------
 playbooks/roles/libvirt_user/tasks/enable-user/debian/main.yml | 1 -
 scripts/guestfs.Makefile                                       | 2 +-
 3 files changed, 1 insertion(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/playbooks/roles/bringup_guestfs/tasks/main.yml b/playbooks/roles/bringup_guestfs/tasks/main.yml
index 07e0fc4..95631aa 100644
--- a/playbooks/roles/bringup_guestfs/tasks/main.yml
+++ b/playbooks/roles/bringup_guestfs/tasks/main.yml
@@ -59,7 +59,6 @@ 
 
 - name: Check dnsmasq service status
   become: yes
-  become_flags: 'su - -c'
   become_method: sudo
   command: systemctl is-enabled dnsmasq
   register: dnsmasq_enabled
@@ -72,7 +71,6 @@ 
 
 - name: Check if dnsmasq service is active
   become: yes
-  become_flags: 'su - -c'
   become_method: sudo
   command: systemctl is-active dnsmasq
   register: dnsmasq_active
@@ -94,7 +92,6 @@ 
 
 - name: Check if libvirt default network is running
   become: yes
-  become_flags: 'su - -c'
   become_method: sudo
   shell: virsh net-list | grep -q default
   register: libvirt_default_net
@@ -106,7 +103,6 @@ 
 - name: Start the libvirt default network if not running
   command: virsh net-start default
   become: yes
-  become_flags: 'su - -c'
   become_method: sudo
   when:
     - 'libvirt_uri_system|bool'
@@ -123,7 +119,6 @@ 
 
 - name: Look for console.log files in guestfs subdirectories to check for CI enablement
   become: yes
-  become_flags: 'su - -c'
   become_method: sudo
   find:
     paths: "{{ topdir_path }}/guestfs"
@@ -137,7 +132,6 @@ 
 
 - name: Ensure console.log files are owned by the main user for CI monitoring
   become: yes
-  become_flags: 'su - -c'
   become_method: sudo
   file:
     path: "{{ item.path }}"
diff --git a/playbooks/roles/libvirt_user/tasks/enable-user/debian/main.yml b/playbooks/roles/libvirt_user/tasks/enable-user/debian/main.yml
index 5797bd6..2fa31ce 100644
--- a/playbooks/roles/libvirt_user/tasks/enable-user/debian/main.yml
+++ b/playbooks/roles/libvirt_user/tasks/enable-user/debian/main.yml
@@ -49,7 +49,6 @@ 
 - name: Ensure our user is part of the libvirt/kvm groups
   tags: [ 'journal', 'build-deps' ]
   become: yes
-  become_flags: 'su - -c'
   become_method: sudo
   ansible.builtin.user:
     name:  "{{ ansible_user_id }}"
diff --git a/scripts/guestfs.Makefile b/scripts/guestfs.Makefile
index dbfb372..480bc4f 100644
--- a/scripts/guestfs.Makefile
+++ b/scripts/guestfs.Makefile
@@ -73,7 +73,7 @@  $(KDEVOPS_PROVISIONED_SSH):
 	$(Q)touch $(KDEVOPS_PROVISIONED_SSH)
 
 bringup_guestfs: $(GUESTFS_BRINGUP_DEPS)
-	$(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \
+	$(Q)ansible-playbook -K $(ANSIBLE_VERBOSE) --connection=local \
 		--inventory localhost, \
 		playbooks/bringup_guestfs.yml \
 		-e 'ansible_python_interpreter=/usr/bin/python3' \