From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9C2C236435 for ; Fri, 30 May 2025 17:52:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748627555; cv=none; b=IWz3XCILdxEP3HDHBkYkl0Gwni7Hy/JPsnDmU4RjxEtTD93B6wKloahfaSPwyOaKAXMun6rrN1EIJHVpQwKBfQkr6hZIEponRi6+a2pjKc8clsy3xq8W4ziwbpmoD2or4tOy1fMZ7/JHbrcTUDfOsYV1M8ZJ58JrE/KT+/lvS/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748627555; c=relaxed/simple; bh=YuVE+LPamjfixkvrictj3QzJl8gA0qLMSTpO54E2gXY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AuS9NZQ6J90x1DZga4zN+H8RqlkBAwCEud5w2CY2yun0fQ4Gniq1uGaggxcIBapJxidjQRnqptM7ehH2hrO2QTe65KArjJQJKKvwJygg2h9QA3Kd+tjgD3Vjvj1fuVZNn6sKJOS9F9OEfVI7tH2Re9q5j7+PwY1avCZ6qccV2BA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kYb83M5L; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kYb83M5L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FDACC4AF09; Fri, 30 May 2025 17:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748627555; bh=YuVE+LPamjfixkvrictj3QzJl8gA0qLMSTpO54E2gXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kYb83M5LFzjZLGJuKxnXLV2cGlg0w394w1Aeo06J4h0AM551923lwcxPB1bd3+Z5t W57hCNPJlMi/N+vcR/1Z3du3YnB14YpfY97En3A5MtfucVNH3tmgZG79q8vwN+QUTf Rz3Z9AGWAcc291ch0AouQNlDHTDfJIPwZNJzWBNLgg684iBiAVEZoUE6c0QvHWkATA duDxAjC9gwttFOTFJoULfoVuPg2rEw8OlolfP0trdf2hVYIhWuPtHObZL4u/i9d6S5 8AboPGmCRB+e7psuAo3F2qhLmAXXC8vK19CAtCtPgz2toqZfyAr+SyFm/lUOJaH91t nVjbdRhb6HzOA== From: Chuck Lever To: Cc: Chuck Lever Subject: [PATCH v2 05/12] guestfs: Copy "network" tag steps to guestfs role Date: Fri, 30 May 2025 13:52:22 -0400 Message-ID: <20250530175229.489925-6-cel@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250530175229.489925-1-cel@kernel.org> References: <20250530175229.489925-1-cel@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chuck Lever Copy the "network" tag steps into the guestfs role to remove a usage of the bringup_guestfs role. Signed-off-by: Chuck Lever --- playbooks/roles/guestfs/defaults/main.yml | 2 + .../roles/guestfs/tasks/bringup/network.yml | 83 +++++++++++++++++++ playbooks/roles/guestfs/tasks/main.yml | 8 ++ scripts/guestfs.Makefile | 5 -- 4 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 playbooks/roles/guestfs/tasks/bringup/network.yml diff --git a/playbooks/roles/guestfs/defaults/main.yml b/playbooks/roles/guestfs/defaults/main.yml index 6112b384bb57..e250a40fd27a 100644 --- a/playbooks/roles/guestfs/defaults/main.yml +++ b/playbooks/roles/guestfs/defaults/main.yml @@ -1,2 +1,4 @@ --- +distro_debian_based: false + libvirt_uri_system: false diff --git a/playbooks/roles/guestfs/tasks/bringup/network.yml b/playbooks/roles/guestfs/tasks/bringup/network.yml new file mode 100644 index 000000000000..8e7c9f1df7f3 --- /dev/null +++ b/playbooks/roles/guestfs/tasks/bringup/network.yml @@ -0,0 +1,83 @@ +--- +- name: Check for dnsmasq configuration files + ansible.builtin.stat: + path: "{{ item }}" + loop: + - /etc/dnsmasq.conf + - /etc/dnsmasq.d + register: dnsmasq_config_files + when: + - distro_debian_based|bool + +- name: Fail if dnsmasq configuration files exist + ansible.builtin.fail: + msg: | + dnsmasq configuration files or directories still exist. + Please remove the following to fully uninstall + dnsmasq:\n{{ dnsmasq_config_files | join('\n') }} + when: + - distro_debian_based|bool + - dnsmasq_config_files.results | selectattr('stat.exists') | list | length > 0 + +- name: Check if dnsmasq service is enabled + # noqa: command-instead-of-module + become: true + become_flags: 'su - -c' + become_method: ansible.builtin.sudo + ansible.builtin.command: + cmd: "systemctl is-enabled dnsmasq" + register: dnsmasq_enabled + failed_when: false + changed_when: false + when: + - distro_debian_based|bool + - dnsmasq_config_files | length > 0 + +- name: Check if dnsmasq service is active + # noqa: command-instead-of-module + become: true + become_flags: 'su - -c' + become_method: ansible.builtin.sudo + ansible.builtin.command: + cmd: "systemctl is-active dnsmasq" + register: dnsmasq_active + failed_when: false + changed_when: false + when: + - distro_debian_based|bool + - dnsmasq_config_files | length > 0 + +- name: Fail if dnsmasq service is enabled or active + ansible.builtin.fail: + msg: | + dnsmasq service is + {{ 'enabled' if dnsmasq_enabled.rc == 0 else 'active' if dnsmasq_active.rc == 0 else 'present' }}. + Please ensure dnsmasq is fully uninstalled and disabled. + Run 'sudo systemctl disable dnsmasq' and 'sudo systemctl + stop dnsmasq' to disable and stop the service. + when: + - distro_debian_based|bool + - dnsmasq_config_files | length > 0 + - (dnsmasq_enabled.rc == 0) or (dnsmasq_active.rc == 0) + +- name: Check if libvirt default network is running + become: true + become_flags: 'su - -c' + become_method: ansible.builtin.sudo + ansible.builtin.shell: virsh net-list | grep -q default + register: libvirt_default_net + ignore_errors: true + changed_when: false + when: + - libvirt_uri_system|bool + +- name: Start the libvirt default network + become: true + become_flags: 'su - -c' + become_method: ansible.builtin.sudo + ansible.builtin.command: + cmd: "virsh net-start default" + changed_when: true + when: + - libvirt_uri_system|bool + - libvirt_default_net.rc != 0 diff --git a/playbooks/roles/guestfs/tasks/main.yml b/playbooks/roles/guestfs/tasks/main.yml index 12064cb91d73..6981d3c1a70b 100644 --- a/playbooks/roles/guestfs/tasks/main.yml +++ b/playbooks/roles/guestfs/tasks/main.yml @@ -13,6 +13,14 @@ ansible.builtin.import_tasks: file: "{{role_path }}/tasks/bringup/storage-pool-path.yml" +- name: Ensure libvirt networking has started + delegate_to: localhost + run_once: true + tags: + - bringup + ansible.builtin.import_tasks: + file: "{{role_path }}/tasks/bringup/network.yml" + - name: Shut down and destroy each target node tags: - destroy diff --git a/scripts/guestfs.Makefile b/scripts/guestfs.Makefile index 571662d187ae..f2900a684960 100644 --- a/scripts/guestfs.Makefile +++ b/scripts/guestfs.Makefile @@ -79,11 +79,6 @@ bringup_guestfs: $(GUESTFS_BRINGUP_DEPS) -i hosts playbooks/guestfs.yml \ --extra-vars=@./extra_vars.yaml \ --tags bringup - $(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \ - --inventory localhost, \ - playbooks/bringup_guestfs.yml \ - --extra-vars=@./extra_vars.yaml \ - --tags network $(Q)$(TOPDIR)/scripts/bringup_guestfs.sh $(Q)ansible-playbook $(ANSIBLE_VERBOSE) --connection=local \ --inventory localhost, \ -- 2.49.0