bootlinux: Modernize install-deps/main.yml
PATCH 1/2 bootlinux: Modernize install-deps/main.yml
From: Chuck Lever <[email protected]>
This subrole is run using include_tasks, but install-deps/main.yml then imports the distribution-specific steps. It's better to avoid mixing import_tasks and include_tasks.
--- .../bootlinux/tasks/install-deps/main.yml | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
playbooks/roles/bootlinux/tasks/install-deps/main.yml +14 -7
@@ -1,8 +1,15 @@ --- -- name: oscheck distribution ospecific setup - import_tasks: debian/main.yml - when: ansible_facts['os_family']|lower == 'debian' -- import_tasks: suse/main.yml - when: ansible_facts['os_family']|lower == 'suse' -- import_tasks: redhat/main.yml - when: ansible_facts['os_family']|lower == 'redhat' +- name: Debian-specific setup + ansible.builtin.include_tasks: debian/main.yml + when: + - ansible_os_family == "Debian" + +- name: SuSE-specific setup + ansible.builtin.include_tasks: suse/main.yml + when: + - ansible_os_family == "Suse" + +- name: Red Hat-specific setup + ansible.builtin.include_tasks: redhat/main.yml + when: + - ansible_os_family == "RedHat"
Signature · 1 line
2.49.0
PATCH 2/2 bootlinux: Fold bootlinux-local into the bootlinux role
From: Chuck Lever <[email protected]>
Rather than running a separate play, adopt the more common mechanism for running a local action.
--- playbooks/bootlinux-local.yml | 5 ----- .../roles/bootlinux-local/defaults/main.yml | 3 --- .../roles/bootlinux-local/tasks/install-deps | 1 - .../roles/bootlinux-local/tasks/main.yml | 19 ---------------- playbooks/roles/bootlinux/tasks/main.yml | 22 ++++++++++++++++--- workflows/linux/Makefile | 3 --- 6 files changed, 19 insertions(+), 34 deletions(-) delete mode 100644 playbooks/bootlinux-local.yml delete mode 100644 playbooks/roles/bootlinux-local/defaults/main.yml delete mode 120000 playbooks/roles/bootlinux-local/tasks/install-deps delete mode 100644 playbooks/roles/bootlinux-local/tasks/main.yml
playbooks/bootlinux-local.yml deleted +0 -5
@@ -1,5 +0,0 @@ ---- -- hosts: localhost - connection: local - roles: - - role: bootlinux-local
playbooks/roles/bootlinux-local/defaults/main.yml deleted +0 -3
@@ -1,3 +0,0 @@ -# SPDX-License-Identifier copyleft-next-0.3.1 ---- -bootlinux_9p: False
playbooks/roles/bootlinux-local/tasks/install-deps deleted +0 -1
@@ -1 +0,0 @@ -../../bootlinux/tasks/install-deps/
playbooks/roles/bootlinux-local/tasks/main.yml deleted +0 -19
@@ -1,19 +0,0 @@ ---- -- name: Import optional extra_args file - include_vars: "{{ item }}" - ignore_errors: yes - with_first_found: - - files: - - "../extra_vars.yml" - - "../extra_vars.yaml" - - "../extra_vars.json" - skip: true - tags: vars - -- name: Install dependencies to build Linux on host - tags: [ 'deps' ] - run_once: true - local_action: import_tasks install-deps/main.yml - when: - - bootlinux_9p|bool -
playbooks/roles/bootlinux/tasks/main.yml +19 -3
@@ -10,11 +10,23 @@ skip: true tags: vars -# Distro specific -- name: Install dependencies - include_tasks: +- name: Install dependencies to build and install the Linux kernel + ansible.builtin.include_tasks: file: install-deps/main.yml +# Needs root on the controller +# +# Someday this should be done only once when installing kdevops +# on the Ansible control node. +- name: Install dependencies to build the Linux kernel + run_once: true + ansible.builtin.include_tasks: + file: install-deps/main.yml + apply: + delegate_to: localhost + when: + - bootlinux_9p|bool + # We do this regardless of what distro you use - name: Install b4 become: yes
@@ -28,6 +40,10 @@ - ansible_facts['os_family']|lower != 'debian' tags: linux +# Needs root on the controller +# +# Someday this should be done only once when installing kdevops +# on the Ansible control node. - name: Install b4 on host become: yes become_method: sudo
workflows/linux/Makefile +0 -3
@@ -90,9 +90,6 @@ LINUX_HELP_EXTRA := PHONY += linux linux: $(KDEVOPS_NODES) - $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \ - $(KDEVOPS_PLAYBOOKS_DIR)/bootlinux-local.yml \ - --extra-vars="$(BOOTLINUX_ARGS)" $(Q)ansible-playbook $(ANSIBLE_VERBOSE) -i \ $(KDEVOPS_HOSTFILE) $(KDEVOPS_PLAYBOOKS_DIR)/bootlinux.yml \ --extra-vars="$(BOOTLINUX_ARGS)" $(LIMIT_HOSTS)
Signature · 1 line
2.49.0
Quoted 5 lines · On 18/05/2025 16.18, [email protected] wrote:
From: Chuck Lever <[email protected]>
This subrole is run using
include_tasks, butinstall-deps/main.ymlthen imports the distribution-specific steps. It's better to avoid mixingimport_tasksandinclude_tasks.
I agree.
Ansible explains tag inheritance recommendation here:
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_tags.html#tag-inheritance-for-includes-blocks-and-the-apply-keyword
Can you add that to the commit message?
Quoted 13 lines
Signed-off-by Chuck Lever <[email protected]>--- .../bootlinux/tasks/install-deps/main.yml | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)playbooks/roles/bootlinux/tasks/install-deps/main.yml +0
-1@@ -1,8 +1,15 @@ --- -- name: oscheck distribution ospecific setup
playbooks/roles/bootlinux/tasks/install-deps/main.yml line 5
Quoted 10 lines
playbooks/roles/bootlinux/tasks/install-deps/main.yml +4
-6- import_tasks: debian/main.yml - when: ansible_facts['os_family']|lower == 'debian' -- import_tasks: suse/main.yml - when: ansible_facts['os_family']|lower == 'suse' -- import_tasks: redhat/main.yml - when: ansible_facts['os_family']|lower == 'redhat' +- name: Debian-specific setup + ansible.builtin.include_tasks: debian/main.yml + when: + - ansible_os_family == "Debian"
In general, I think Ansible import is preferred for simplicity. The include_tasks module forces us to be explicit with the tags at 'include_*' task and at every included task level. Here, no tags are applied but debian/main.yml uses the linux tag. So if the playbook is run without specifying a tag (i.e. through linux Makefile target), I believe the file will be included but no tasks will be executed. Is that correct?
Re: [PATCH v1 2/2] bootlinux: Fold bootlinux-local into the bootlinux role
In reply to [email protected]Quoted 77 lines · On 18/05/2025 16.18, [email protected] wrote:
From: Chuck Lever <[email protected]>
Rather than running a separate play, adopt the more common mechanism for running a local action.
Signed-off-by Chuck Lever <[email protected]>--- playbooks/bootlinux-local.yml | 5 ----- .../roles/bootlinux-local/defaults/main.yml | 3 --- .../roles/bootlinux-local/tasks/install-deps | 1 - .../roles/bootlinux-local/tasks/main.yml | 19 ---------------- playbooks/roles/bootlinux/tasks/main.yml | 22 ++++++++++++++++--- workflows/linux/Makefile | 3 --- 6 files changed, 19 insertions(+), 34 deletions(-)delete mode 100644
playbooks/bootlinux-local.yml
delete mode 100644playbooks/roles/bootlinux-local/defaults/main.ymldelete mode 120000 playbooks/roles/bootlinux-local/tasks/install-deps delete mode 100644playbooks/roles/bootlinux-local/tasks/main.ymlplaybooks/bootlinux-local.yml deleted +0
-5@@ -1,5 +0,0 @@ ---- -- hosts: localhost - connection: local - roles: - - role: bootlinux-localplaybooks/roles/bootlinux-local/defaults/main.yml deleted +0
-3@@ -1,3 +0,0 @@ -# SPDX-License-Identifier copyleft-next-0.3.1 ---- -bootlinux_9p: Falseplaybooks/roles/bootlinux-local/tasks/install-deps deleted +0
-1@@ -1 +0,0 @@ -../../bootlinux/tasks/install-deps/playbooks/roles/bootlinux-local/tasks/main.yml deleted +0
-19@@ -1,19 +0,0 @@ ---- -- name: Import optional extra_args file - include_vars: "{{ item }}" - ignore_errors: yes - with_first_found: - - files: - - "../extra_vars.yml" - - "../extra_vars.yaml" - - "../extra_vars.json" - skip: true - tags: vars - -- name: Install dependencies to build Linux on host - tags: [ 'deps' ] - run_once: true - local_action: import_tasks install-deps/main.yml - when: - - bootlinux_9p|bool -playbooks/roles/bootlinux/tasks/main.yml +0
-0
playbooks/roles/bootlinux/tasks/main.yml line 16
Quoted 10 lines
playbooks/roles/bootlinux/tasks/main.yml +2
-3@@ -10,11 +10,23 @@ skip: true tags: vars -# Distro specific -- name: Install dependencies - include_tasks: +- name: Install dependencies to build and install the Linux kernel + ansible.builtin.include_tasks: file: install-deps/main.yml
Same comment as in the other patch. Either we are missing deps tags here, at the Makefile target and at task level (and replace it with the current linux tag) or just remove all of them.
Quoted 17 lines
playbooks/roles/bootlinux/tasks/main.yml +13
-0+# Needs root on the controller +# +# Someday this should be done only once when installing kdevops +# on the Ansible control node. +- name: Install dependencies to build the Linux kernel + run_once: true + ansible.builtin.include_tasks: + file: install-deps/main.yml + apply: + delegate_to: localhost + when: + - bootlinux_9p|bool + # We do this regardless of what distro you use - name: Install b4 become: yes
playbooks/roles/bootlinux/tasks/main.yml line 46
Quoted 7 lines
playbooks/roles/bootlinux/tasks/main.yml +4
-0@@ -28,6 +40,10 @@ - ansible_facts['os_family']|lower != 'debian' tags: linux +# Needs root on the controller +# +# Someday this should be done only once when installing kdevops +# on the Ansible control node.
@yawn_brendan shared this idea of running kdevops inside LXC with kvm support. Otherwise, host setup may become a bit complex to do it manually.
Thoughts?
Quoted 17 lines
playbooks/roles/bootlinux/tasks/main.yml +0
-0- name: Install b4 on host become: yes become_method: sudoworkflows/linux/Makefile +0
-3@@ -90,9 +90,6 @@ LINUX_HELP_EXTRA := PHONY += linux linux: $(KDEVOPS_NODES) - $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \ - $(KDEVOPS_PLAYBOOKS_DIR)/bootlinux-local.yml \ - --extra-vars="$(BOOTLINUX_ARGS)" $(Q)ansible-playbook $(ANSIBLE_VERBOSE) -i \ $(KDEVOPS_HOSTFILE) $(KDEVOPS_PLAYBOOKS_DIR)/bootlinux.yml \ --extra-vars="$(BOOTLINUX_ARGS)" $(LIMIT_HOSTS)
Quoted 7 lines · Daniel Gomez
Quoted 5 lines · On 18/05/2025 16.18, [email protected] wrote:
From: Chuck Lever <[email protected]>
This subrole is run using
include_tasks, butinstall-deps/main.ymlthen imports the distribution-specific steps. It's better to avoid mixingimport_tasksandinclude_tasks.
Quoted 8 lines
I agree.
Ansible explains tag inheritance recommendation here:
https://docs.ansible.com/ansible/latest/playbook_guide/
playbooks_tags.html#tag-inheritance-for-includes-blocks-and-the-apply- keywordCan you add that to the commit message?
Yes.
Quoted 24 lines
Quoted 15 lines
Signed-off-by Chuck Lever <[email protected]>---
.../bootlinux/tasks/install-deps/main.yml | 21 ++++++++++++-------1 file changed, 14 insertions(+), 7 deletions(-)(quoted diff) renamed from playbooks/roles/bootlinux/tasks/install-deps/main.yml +0
-0
playbooks/roles/bootlinux/tasks/install-deps/main.ymlindexc4c16d20509c..2931f9fe06e3100644playbooks/roles/bootlinux/tasks/install-deps/main.yml +0
-0@@ -1,8 +1,15 @@---
-- name: oscheck distribution ospecific setup -import_tasks:debian/main.yml
- when: ansible_facts['os_family']|lower == 'debian'Quoted 8 lines
--
import_tasks:suse/main.yml
- when: ansible_facts['os_family']|lower == 'suse' --import_tasks:redhat/main.yml
- when: ansible_facts['os_family']|lower == 'redhat' +- name: Debian-specific setup
+ ansible.builtin.include_tasks:debian/main.yml+ when:
+ -ansible_os_family== "Debian"
Quoted 8 lines
In general, I think Ansible import is preferred for simplicity. The
include_tasksmodule forces us to be explicit with the tags at 'include_*' task and at every included task level. Here, no tags are applied butdebian/main.ymluses the linux tag. So if the playbook is run without specifying a tag (i.e. through linuxMakefiletarget), I believe the file will be included but no tasks will be executed. Is that correct?
The "linux" tag is not set by any invocation of this role. I have a patch that removes the tag completely. I can include that patch when I repost.
I went back and forth about whether to stick with import_tasks or change to include_tasks, and I can't remember why I went with include_tasks. So right at the moment, I'm not stuck on either one or the other.
Signature · 1 line
Chuck Lever
Re: [PATCH v1 2/2] bootlinux: Fold bootlinux-local into the bootlinux role
In reply to Daniel GomezQuoted 126 lines · Daniel Gomez
Quoted 83 lines · On 18/05/2025 16.18, [email protected] wrote:
From: Chuck Lever <[email protected]>
Rather than running a separate play, adopt the more common mechanism for running a local action.
Signed-off-by Chuck Lever <[email protected]>---
playbooks/bootlinux-local.yml | 5 ----- .../roles/bootlinux-local/defaults/main.yml | 3 --- .../roles/bootlinux-local/tasks/install-deps | 1 - .../roles/bootlinux-local/tasks/main.yml | 19 ---------------- playbooks/roles/bootlinux/tasks/main.yml | 22 ++++++++++++++++--- workflows/linux/Makefile | 3 ---6 files changed, 19 insertions(+), 34 deletions(-)delete mode 100644
playbooks/bootlinux-local.yml
delete mode 100644playbooks/roles/bootlinux-local/defaults/main.ymldelete mode 120000 playbooks/roles/bootlinux-local/tasks/install-deps delete mode 100644playbooks/roles/bootlinux-local/tasks/main.ymlplaybooks/bootlinux- renamed from playbooks/bootlinux-local.yml +0
-0local.yml
deleted file mode 100644
index e342f0e56fb1..000000000000playbooks/bootlinux-local.yml deleted +0
-5@@ -1,5 +0,0 @@ ---- -- hosts: localhost - connection: local - roles: - - role: bootlinux-local(quoted diff) renamed from playbooks/roles/bootlinux-local/defaults/main.yml +0
-0
playbooks/roles/bootlinux-local/defaults/main.yml
deleted file mode 100644
index d7c41f4c3e90..000000000000playbooks/roles/bootlinux-local/defaults/main.yml deleted +0
-3@@ -1,3 +0,0 @@ -# SPDX-License-Identifier copyleft-next-0.3.1 ---- -bootlinux_9p: False(quoted diff) renamed from playbooks/roles/bootlinux-local/tasks/install-deps +0
-0playbooks/roles/bootlinux-local/tasks/install-deps deleted file mode 120000
index 492aaaa0174a..000000000000playbooks/roles/bootlinux-local/tasks/install-deps deleted +0
-1@@ -1 +0,0 @@ -../../bootlinux/tasks/install-deps/(quoted diff) renamed from playbooks/roles/bootlinux-local/tasks/main.yml +0
-0
playbooks/roles/bootlinux-local/tasks/main.yml
deleted file mode 100644
index 367b3af46ec6..000000000000playbooks/roles/bootlinux-local/tasks/main.yml deleted +0
-19@@ -1,19 +0,0 @@ ---- -- name: Import optional extra_args file - include_vars: "{{ item }}" - ignore_errors: yes - with_first_found: - - files: - - "../extra_vars.yml" - - "../extra_vars.yaml" - - "../extra_vars.json" - skip: true - tags: vars - -- name: Install dependencies to build Linux on host - tags: [ 'deps' ] - run_once: true - local_action: import_tasks install-deps/main.yml - when: - - bootlinux_9p|bool -playbooks/ renamed from playbooks/roles/bootlinux/tasks/main.yml +0
-0
roles/bootlinux/tasks/main.yml
index9ad675b3f278..3741b16aa33c100644playbooks/roles/bootlinux/tasks/main.yml +0
-0@@ -10,11 +10,23 @@skip: true
Quoted 8 lines
tags: vars
-# Distro specific
-- name: Install dependencies
-include_tasks:
+- name: Install dependencies to build and install the Linux kernel + ansible.builtin.include_tasks:
file:install-deps/main.ymlSame comment as in the other patch. Either we are missing deps tags here, at the
Makefiletarget and at task level (and replace it with the current linux tag) or just remove all of them.Quoted 20 lines
playbooks/roles/bootlinux/tasks/main.yml +13
-0+# Needs root on the controller +# +# Someday this should be done only once when installing kdevops +# on the Ansible control node. +- name: Install dependencies to build the Linux kernel + run_once: true + ansible.builtin.include_tasks: + file: install-deps/main.yml + apply: + delegate_to: localhost + when: + - bootlinux_9p|bool +# We do this regardless of what distro you use
- name: Install b4
become: yesplaybooks/roles/bootlinux/tasks/main.yml +0
-0@@ -28,6 +40,10 @@- ansible_facts['os_family']|lower != 'debian'
tags: linux
+# Needs root on the controllerplaybooks/roles/bootlinux/tasks/main.yml line 20
Quoted 3 lines
playbooks/roles/bootlinux/tasks/main.yml +3
-0+# +# Someday this should be done only once when installing kdevops +# on the Ansible control node.@yawn_brendan shared this idea of running kdevops inside LXC with kvm support. Otherwise, host setup may become a bit complex to do it manually.
Quoted 1 line
Thoughts?
Where I'm going with this is to ultimately remove the use of "sudo" for all local actions. The biggest user of sudo for that purpose seems to be installing dependencies on the controller. That can instead be done when kdevops is installed.
But LXC/kvm is outside of my everyday usage, so perhaps I don't understand @yawn_brendan's suggestion.
Quoted 17 lines
Quoted 16 lines
- name: Install b4 on host
become: yes
become_method: sudoworkflows/linux/Makefile +0
-0@@ -90,9 +90,6 @@ LINUX_HELP_EXTRA :=PHONY += linux
linux: $(KDEVOPS_NODES)
- $(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
- $(KDEVOPS_PLAYBOOKS_DIR)/bootlinux-local.yml \
- --extra-vars="$(BOOTLINUX_ARGS)" $(Q)ansible-playbook $(ANSIBLE_VERBOSE) -i \
$(KDEVOPS_HOSTFILE) $(KDEVOPS_PLAYBOOKS_DIR)/bootlinux.yml \
--extra-vars="$(BOOTLINUX_ARGS)" $(LIMIT_HOSTS)
Signature · 1 line
Chuck Lever
Re: [PATCH v1 2/2] bootlinux: Fold bootlinux-local into the bootlinux role
Quoted 127 lines · Chuck Lever
Quoted 126 lines · Daniel Gomez
Quoted 82 lines · On 18/05/2025 16.18, [email protected] wrote:
From: Chuck Lever <[email protected]>
Rather than running a separate play, adopt the more common mechanism for running a local action.
Signed-off-by Chuck Lever <[email protected]>--- playbooks/bootlinux-local.yml | 5 ----- .../roles/bootlinux-local/defaults/main.yml | 3 --- .../roles/bootlinux-local/tasks/install-deps | 1 - .../roles/bootlinux-local/tasks/main.yml | 19 ---------------- playbooks/roles/bootlinux/tasks/main.yml | 22 ++++++++++++++++--- workflows/linux/Makefile | 3 --- 6 files changed, 19 insertions(+), 34 deletions(-)delete mode 100644
playbooks/bootlinux-local.yml
delete mode 100644playbooks/roles/bootlinux-local/defaults/main.ymldelete mode 120000 playbooks/roles/bootlinux-local/tasks/install-deps delete mode 100644playbooks/roles/bootlinux-local/tasks/main.ymlplaybooks/bootlinux- renamed from playbooks/bootlinux-local.yml +0
-0local.yml
deleted file mode 100644
index e342f0e56fb1..000000000000playbooks/bootlinux-local.yml deleted +0
-5@@ -1,5 +0,0 @@ ---- -- hosts: localhost - connection: local - roles: - - role: bootlinux-local(quoted diff) renamed from playbooks/roles/bootlinux-local/defaults/main.yml +0
-0
playbooks/roles/bootlinux-local/defaults/main.yml
deleted file mode 100644
index d7c41f4c3e90..000000000000playbooks/roles/bootlinux-local/defaults/main.yml deleted +0
-3@@ -1,3 +0,0 @@ -# SPDX-License-Identifier copyleft-next-0.3.1 ---- -bootlinux_9p: False(quoted diff) renamed from playbooks/roles/bootlinux-local/tasks/install-deps +0
-0playbooks/roles/bootlinux-local/tasks/install-deps deleted file mode 120000
index 492aaaa0174a..000000000000playbooks/roles/bootlinux-local/tasks/install-deps deleted +0
-1@@ -1 +0,0 @@ -../../bootlinux/tasks/install-deps/(quoted diff) renamed from playbooks/roles/bootlinux-local/tasks/main.yml +0
-0
playbooks/roles/bootlinux-local/tasks/main.yml
deleted file mode 100644
index 367b3af46ec6..000000000000playbooks/roles/bootlinux-local/tasks/main.yml deleted +0
-19@@ -1,19 +0,0 @@ ---- -- name: Import optional extra_args file - include_vars: "{{ item }}" - ignore_errors: yes - with_first_found: - - files: - - "../extra_vars.yml" - - "../extra_vars.yaml" - - "../extra_vars.json" - skip: true - tags: vars - -- name: Install dependencies to build Linux on host - tags: [ 'deps' ] - run_once: true - local_action: import_tasks install-deps/main.yml - when: - - bootlinux_9p|bool -playbooks/ renamed from playbooks/roles/bootlinux/tasks/main.yml +0
-0
roles/bootlinux/tasks/main.yml
index9ad675b3f278..3741b16aa33c100644playbooks/roles/bootlinux/tasks/main.yml line 16
Quoted 9 lines
playbooks/roles/bootlinux/tasks/main.yml +2
-2@@ -10,11 +10,23 @@ skip: true tags: vars -# Distro specific -- name: Install dependencies - include_tasks: +- name: Install dependencies to build and install the Linux kernel + ansible.builtin.include_tasks: file: install-deps/main.ymlSame comment as in the other patch. Either we are missing deps tags here, at the
Makefiletarget and at task level (and replace it with the current linux tag) or just remove all of them.Quoted 17 lines
playbooks/roles/bootlinux/tasks/main.yml +13
-0+# Needs root on the controller +# +# Someday this should be done only once when installing kdevops +# on the Ansible control node. +- name: Install dependencies to build the Linux kernel + run_once: true + ansible.builtin.include_tasks: + file: install-deps/main.yml + apply: + delegate_to: localhost + when: + - bootlinux_9p|bool + # We do this regardless of what distro you use - name: Install b4 become: yesplaybooks/roles/bootlinux/tasks/main.yml line 45
Quoted 6 lines
playbooks/roles/bootlinux/tasks/main.yml +3
-0@@ -28,6 +40,10 @@ - ansible_facts['os_family']|lower != 'debian' tags: linux +# Needs root on the controller +# +# Someday this should be done only once when installing kdevops +# on the Ansible control node.@yawn_brendan shared this idea of running kdevops inside LXC with kvm support. Otherwise, host setup may become a bit complex to do it manually.
Quoted 7 lines
Quoted 1 line
Thoughts?
Where I'm going with this is to ultimately remove the use of "sudo" for all local actions. The biggest user of sudo for that purpose seems to be installing dependencies on the controller. That can instead be done when kdevops is installed.
I agree that would be great. But I'm not sure if that can apply to all workflows, setups, etc. That said, we should apply where we can.
Quoted 2 lines
But LXC/kvm is outside of my everyday usage, so perhaps I don't understand @yawn_brendan's suggestion.
We do more than installing dependencies with sudo. Like managing systemd services (user or system), configuring system wide stuff at /etc/*, etc. As an alternative to remove sudo, if we enable users to run kdevops inside a container with systemd like distrobox then, kdevops users would not be worried about what sudo does in that environment. At least, while we work on removing sudo.
Re: [PATCH v1 2/2] bootlinux: Fold bootlinux-local into the bootlinux role
Quoted 135 lines · Daniel Gomez
Quoted 132 lines · Chuck Lever
Quoted 130 lines · Daniel Gomez
Quoted 85 lines · On 18/05/2025 16.18, [email protected] wrote:
From: Chuck Lever <[email protected]>
Rather than running a separate play, adopt the more common mechanism for running a local action.
Signed-off-by Chuck Lever <[email protected]>---
playbooks/bootlinux-local.yml | 5 ----- .../roles/bootlinux-local/defaults/main.yml | 3 --- .../roles/bootlinux-local/tasks/install-deps | 1 - .../roles/bootlinux-local/tasks/main.yml | 19 ---------------- playbooks/roles/bootlinux/tasks/main.yml | 22 ++++++++++++++
++---
workflows/linux/Makefile | 3 ---6 files changed, 19 insertions(+), 34 deletions(-)delete mode 100644
playbooks/bootlinux-local.yml
delete mode 100644playbooks/roles/bootlinux-local/defaults/main.ymldelete mode 120000 playbooks/roles/bootlinux-local/tasks/install- deps
delete mode 100644playbooks/roles/bootlinux-local/tasks/main.ymlplaybooks/bootlinux- renamed from playbooks/bootlinux-local.yml +0
-0local.yml
deleted file mode 100644
index e342f0e56fb1..000000000000playbooks/bootlinux-local.yml deleted +0
-5@@ -1,5 +0,0 @@ ---- -- hosts: localhost - connection: local - roles: - - role: bootlinux-local(quoted diff) renamed from playbooks/roles/bootlinux-local/defaults/main.yml +0
-0
playbooks/roles/bootlinux-local/defaults/main.yml
deleted file mode 100644
index d7c41f4c3e90..000000000000playbooks/roles/bootlinux-local/defaults/main.yml deleted +0
-3@@ -1,3 +0,0 @@ -# SPDX-License-Identifier copyleft-next-0.3.1 ---- -bootlinux_9p: False(quoted diff) renamed from playbooks/roles/bootlinux-local/tasks/install-deps +0
-0playbooks/roles/bootlinux-local/tasks/install-deps deleted file mode 120000
index 492aaaa0174a..000000000000playbooks/roles/bootlinux-local/tasks/install-deps deleted +0
-1@@ -1 +0,0 @@ -../../bootlinux/tasks/install-deps/(quoted diff) renamed from playbooks/roles/bootlinux-local/tasks/main.yml +0
-0
playbooks/roles/bootlinux-local/tasks/main.yml
deleted file mode 100644
index 367b3af46ec6..000000000000playbooks/roles/bootlinux-local/tasks/main.yml deleted +0
-19@@ -1,19 +0,0 @@ ---- -- name: Import optional extra_args file - include_vars: "{{ item }}" - ignore_errors: yes - with_first_found: - - files: - - "../extra_vars.yml" - - "../extra_vars.yaml" - - "../extra_vars.json" - skip: true - tags: vars - -- name: Install dependencies to build Linux on host - tags: [ 'deps' ] - run_once: true - local_action: import_tasks install-deps/main.yml - when: - - bootlinux_9p|bool -playbooks/ renamed from playbooks/roles/bootlinux/tasks/main.yml +0
-0
roles/bootlinux/tasks/main.yml
index9ad675b3f278..3741b16aa33c100644playbooks/roles/bootlinux/tasks/main.yml +0
-0@@ -10,11 +10,23 @@skip: true
Quoted 8 lines
tags: vars
-# Distro specific
-- name: Install dependencies
-include_tasks:
+- name: Install dependencies to build and install the Linux kernel + ansible.builtin.include_tasks:
file:install-deps/main.ymlSame comment as in the other patch. Either we are missing deps tags here, at the
Makefiletarget and at task level (and replace it with the current linux tag) or just remove all of them.Quoted 20 lines
playbooks/roles/bootlinux/tasks/main.yml +13
-0+# Needs root on the controller +# +# Someday this should be done only once when installing kdevops +# on the Ansible control node. +- name: Install dependencies to build the Linux kernel + run_once: true + ansible.builtin.include_tasks: + file: install-deps/main.yml + apply: + delegate_to: localhost + when: + - bootlinux_9p|bool +# We do this regardless of what distro you use
- name: Install b4
become: yesplaybooks/roles/bootlinux/tasks/main.yml +0
-0@@ -28,6 +40,10 @@- ansible_facts['os_family']|lower != 'debian'
tags: linux
+# Needs root on the controllerplaybooks/roles/bootlinux/tasks/main.yml line 20
Quoted 3 lines
playbooks/roles/bootlinux/tasks/main.yml +3
-0+# +# Someday this should be done only once when installing kdevops +# on the Ansible control node.@yawn_brendan shared this idea of running kdevops inside LXC with kvm support. Otherwise, host setup may become a bit complex to do it manually.
Thoughts?
Quoted 8 lines
Quoted 5 lines
Where I'm going with this is to ultimately remove the use of "sudo" for all local actions. The biggest user of sudo for that purpose seems to be installing dependencies on the controller. That can instead be done when kdevops is installed.
I agree that would be great. But I'm not sure if that can apply to all workflows, setups, etc. That said, we should apply where we can.
Agreed. The process of finding and removing these will take some time, and the replacement mechanism doesn't yet exist (eg, packaging kdevops via RPM, say).
Quoted 5 lines
Quoted 2 lines
But LXC/kvm is outside of my everyday usage, so perhaps I don't understand @yawn_brendan's suggestion.
We do more than installing dependencies with sudo. Like managing systemd services (user or system), configuring system wide stuff at
/etc/*, etc.
Yes. Luis also mentioned the use of the libvirt system URI.
Quoted 4 lines
As an alternative to remove sudo, if we enable users to run kdevops inside a container with systemd like distrobox then, kdevops users would not be worried about what sudo does in that environment. At least, while we work on removing sudo.
"sudo" on target nodes and in other environments that are managed by Ansible -- that's all OK.
Signature · 1 line
Chuck Lever
Quoted 53 lines · Chuck Lever
Quoted 7 lines · Daniel Gomez
Quoted 5 lines · On 18/05/2025 16.18, [email protected] wrote:
From: Chuck Lever <[email protected]>
This subrole is run using
include_tasks, butinstall-deps/main.ymlthen imports the distribution-specific steps. It's better to avoid mixingimport_tasksandinclude_tasks.Quoted 8 lines
I agree.
Ansible explains tag inheritance recommendation here:
https://docs.ansible.com/ansible/latest/playbook_guide/
playbooks_tags.html#tag-inheritance-for-includes-blocks-and-the-apply- keywordCan you add that to the commit message?
Yes.
Quoted 24 lines
Quoted 13 lines
Signed-off-by Chuck Lever <[email protected]>--- .../bootlinux/tasks/install-deps/main.yml | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)(quoted diff) renamed from playbooks/roles/bootlinux/tasks/install-deps/main.yml +0
-0
playbooks/roles/bootlinux/tasks/install-deps/main.ymlindexc4c16d20509c..2931f9fe06e3100644playbooks/roles/bootlinux/tasks/install-deps/main.yml +0
-1@@ -1,8 +1,15 @@ --- -- name: oscheck distribution ospecific setupplaybooks/roles/bootlinux/tasks/install-deps/main.yml line 5
Quoted 10 lines
playbooks/roles/bootlinux/tasks/install-deps/main.yml +4
-6- import_tasks: debian/main.yml - when: ansible_facts['os_family']|lower == 'debian' -- import_tasks: suse/main.yml - when: ansible_facts['os_family']|lower == 'suse' -- import_tasks: redhat/main.yml - when: ansible_facts['os_family']|lower == 'redhat' +- name: Debian-specific setup + ansible.builtin.include_tasks: debian/main.yml + when: + - ansible_os_family == "Debian"Quoted 8 lines
In general, I think Ansible import is preferred for simplicity. The
include_tasksmodule forces us to be explicit with the tags at 'include_*' task and at every included task level. Here, no tags are applied butdebian/main.ymluses the linux tag. So if the playbook is run without specifying a tag (i.e. through linuxMakefiletarget), I believe the file will be included but no tasks will be executed. Is that correct?
Quoted 3 lines
The "linux" tag is not set by any invocation of this role. I have a patch that removes the tag completely. I can include that patch when I repost.
Cool.
Quoted 7 lines
I went back and forth about whether to stick with
import_tasksor change toinclude_tasks, and I can't remember why I went withinclude_tasks. So right at the moment, I'm not stuck on either one or the other.
My understanding is that import_tasks allows you to not having to use tags inside the import_tasks YAML file. For example:
- name: Import tasks
import_tasks: tasks/deps/debian/main.yml
tags: [ 'tag1', 'tag2', 'tag3']
Tags are evaluated at the "Import tasks" task. We don't need to specify them in debian/main.yml. So, in tasks/deps/debian/main.yml, we can write:
- name: Task1
debug:
msg: "Task1"
- name: Task2
debug:
msg: "Task2"
- name: Task3
debug:
msg: "Task3"
However, if we want debian/main.yml to run task1 with tag1, and so on. We need the include_task module. And write the tags at both levels. So, for simple sub-roles we can stick with import_tasks.
For this case, I'd stick with import_tasks module and remove any tag inside. And apply the necessary tags at the import_task task level.
I hope I'm not missing anything. I can't remember if there was a special case where tags were described at task level but no tags were supplied with --tags.