From be5f1196d87a4013a6e744991e67e135f2380d47 Mon Sep 17 00:00:00 2001 From: seven beep Date: Fri, 20 Sep 2024 21:17:50 +0200 Subject: [PATCH 1/5] feat: Allow to exclude dotfiles on pillar data --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ copy-all.sls | 5 +++++ copy-dom0.sls | 6 ++++++ copy-git.sls | 6 ++++++ copy-gtk.sls | 6 ++++++ copy-mutt.sls | 6 ++++++ copy-net.sls | 6 ++++++ copy-pgp.sls | 6 ++++++ copy-sh.sls | 6 ++++++ copy-ssh.sls | 6 ++++++ copy-tmux.sls | 6 ++++++ copy-vim.sls | 6 ++++++ copy-x11.sls | 6 ++++++ copy-xfce.sls | 6 ++++++ 14 files changed, 121 insertions(+) diff --git a/README.md b/README.md index 772fa31..d350f69 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ @@ -13,6 +14,7 @@ Dotfiles. * [Description](#description) * [Installation](#installation) * [Salt](#salt) + * [Pillar](#pillar) * [Script](#script) * [Usage](#usage) * [License](#license) @@ -59,6 +61,48 @@ Install specific files in Dom0: sudo qubesctl state.apply dotfiles.copy-dom0,dotfiles.copy-sh,dotfiles.copy-vim,dotfiles.copy-x11 ``` +#### Pillar + +With salt, each state execution can be opt out by topic via a corresponding +pillar set to a non true value (eg: Setting qusal:dotfiles:dom0 to false will +disable states specific to dom0, setting qusal:dotfiles:git to false will +disable states specific to git). + +You will need a top file and a sls file in your pillar_roots, when following +[the Qusal's installation instructions](https://github.com/ben-grande/qusal/blob/main/docs/INSTALL.md), +`/srv/pillar/qusal` will be added to you pillar_roots. + +By default, the formulas assume that you opt-in for all dotfiles. + +Example: /srv/pillar/qusal/dotfiles.top: + +```yaml +base: + '*': + - qusal.dotfiles +``` + +It will apply the qusal/dotfiles sls to all targets. + +Example: /srv/pillar/qusal/dotfiles.sls containing the data to pass to the +targets: + +```yaml +qusal: + dotfiles: + dom0: false +``` + +It will disable the dom0 dotfiles configuration. + +Enable the pillar top above: + +```sh +sudo qubesctl top.enable qusal.dotfiles pillar=true +``` + +Now subsequent calls to the states of this repository will skip copy-dom0. + ### Script You can simply deploy all configurations with: diff --git a/copy-all.sls b/copy-all.sls index 065e260..719446c 100644 --- a/copy-all.sls +++ b/copy-all.sls @@ -1,9 +1,12 @@ {# SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if salt['pillar.get']('qusal:dotfiles:all', default=true) == true -%} + include: - .copy-dom0 - .copy-git @@ -17,6 +20,8 @@ include: - .copy-x11 - .copy-xfce +{%- endif -%} + {# Unfortunately salt.states.file does not keep permissions when using salt-ssh. Best option is 'file.managed mode: keep' or 'file.recurse file_mode: keep'. diff --git a/copy-dom0.sls b/copy-dom0.sls index 88ba0af..57a4bf0 100644 --- a/copy-dom0.sls +++ b/copy-dom0.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:dom0', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-dom0-home": @@ -25,3 +29,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - user: root - group: root - makedirs: True + +{%- endif %} diff --git a/copy-git.sls b/copy-git.sls index 7d1a0e1..74b6252 100644 --- a/copy-git.sls +++ b/copy-git.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:git', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-git-home": @@ -65,3 +69,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - mode: '0755' - recurse: - mode + +{%- endif %} diff --git a/copy-gtk.sls b/copy-gtk.sls index 0219472..926b856 100644 --- a/copy-gtk.sls +++ b/copy-gtk.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:gtk', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-gtk-home": @@ -23,3 +27,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - dir_mode: '0700' - user: root - group: root + +{%- endif %} diff --git a/copy-mutt.sls b/copy-mutt.sls index 5c5affe..1cb6922 100644 --- a/copy-mutt.sls +++ b/copy-mutt.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:mutt', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-mutt-home": @@ -25,3 +29,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - user: root - group: root - makedirs: True + +{%- endif %} diff --git a/copy-net.sls b/copy-net.sls index 49bfbd9..65415c9 100644 --- a/copy-net.sls +++ b/copy-net.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:net', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-net-home": @@ -27,3 +31,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - group: root - keep_symlinks: True - force_symlinks: True + +{%- endif %} diff --git a/copy-pgp.sls b/copy-pgp.sls index a2e4b68..4c4461d 100644 --- a/copy-pgp.sls +++ b/copy-pgp.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:gpg', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-pgp-home": @@ -23,3 +27,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - dir_mode: '0700' - user: root - group: root + +{%- endif %} diff --git a/copy-sh.sls b/copy-sh.sls index 6052050..a1273a2 100644 --- a/copy-sh.sls +++ b/copy-sh.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:sh', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-sh-home": @@ -43,3 +47,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - dir_mode: '0755' - recurse: - mode + +{%- endif %} diff --git a/copy-ssh.sls b/copy-ssh.sls index 3c2f112..042756a 100644 --- a/copy-ssh.sls +++ b/copy-ssh.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:ssh', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-ssh-home": @@ -24,3 +28,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - dir_mode: '0700' - user: root - group: root + +{%- endif %} diff --git a/copy-tmux.sls b/copy-tmux.sls index c6951d5..b87ecbd 100644 --- a/copy-tmux.sls +++ b/copy-tmux.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:tmux', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-tmux-home": @@ -37,3 +41,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - mode: '0755' - recurse: - mode + +{%- endif %} diff --git a/copy-vim.sls b/copy-vim.sls index 46771b6..2e1da3d 100644 --- a/copy-vim.sls +++ b/copy-vim.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:vim', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-vim-home": @@ -23,3 +27,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - dir_mode: '0700' - user: root - group: root + +{%- endif %} diff --git a/copy-x11.sls b/copy-x11.sls index 5601a03..91a1eb8 100644 --- a/copy-x11.sls +++ b/copy-x11.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:x11', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-x11-home": @@ -27,3 +31,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - group: root - keep_symlinks: True - force_symlinks: True + +{%- endif %} diff --git a/copy-xfce.sls b/copy-xfce.sls index b4cc720..fe15a09 100644 --- a/copy-xfce.sls +++ b/copy-xfce.sls @@ -1,9 +1,13 @@ {# SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. +SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} +{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) + and (salt['pillar.get']('qusal:dotfiles:xfce', default=true) == true )) -%} + {%- import "dom0/gui-user.jinja" as gui_user -%} "{{ slsdotpath }}-copy-xfce-home": @@ -27,3 +31,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later - group: root - keep_symlinks: True - force_symlinks: True + +{%- endif %} From 82ed415c0a09a92f83629109da2da4b47c32d282 Mon Sep 17 00:00:00 2001 From: seven beep Date: Wed, 2 Oct 2024 22:34:07 +0200 Subject: [PATCH 2/5] Fix: Prevent error return code on void includes The include statement will return an error code 20 if no data is included. Their is three ways to fix this: - boilerplate jinja2 around each includes - include a dummy file with at least a function that do nothing - a function that does nothing in the included files I chose the third as I found that signaling to the user the effects of its pillar configuration is a good thing. --- copy-all.sls | 5 +++++ copy-dom0.sls | 5 +++++ copy-git.sls | 5 +++++ copy-gtk.sls | 5 +++++ copy-mutt.sls | 5 +++++ copy-net.sls | 5 +++++ copy-pgp.sls | 5 +++++ copy-sh.sls | 5 +++++ copy-ssh.sls | 5 +++++ copy-tmux.sls | 5 +++++ copy-vim.sls | 5 +++++ copy-x11.sls | 5 +++++ copy-xfce.sls | 5 +++++ 13 files changed, 65 insertions(+) diff --git a/copy-all.sls b/copy-all.sls index 719446c..be8d97d 100644 --- a/copy-all.sls +++ b/copy-all.sls @@ -20,6 +20,11 @@ include: - .copy-x11 - .copy-xfce +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif -%} {# diff --git a/copy-dom0.sls b/copy-dom0.sls index 57a4bf0..c71a7d2 100644 --- a/copy-dom0.sls +++ b/copy-dom0.sls @@ -30,4 +30,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - group: root - makedirs: True +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-git.sls b/copy-git.sls index 74b6252..7c86521 100644 --- a/copy-git.sls +++ b/copy-git.sls @@ -70,4 +70,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - recurse: - mode +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-gtk.sls b/copy-gtk.sls index 926b856..699112b 100644 --- a/copy-gtk.sls +++ b/copy-gtk.sls @@ -28,4 +28,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - user: root - group: root +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-mutt.sls b/copy-mutt.sls index 1cb6922..1df8af0 100644 --- a/copy-mutt.sls +++ b/copy-mutt.sls @@ -30,4 +30,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - group: root - makedirs: True +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-net.sls b/copy-net.sls index 65415c9..40e7294 100644 --- a/copy-net.sls +++ b/copy-net.sls @@ -32,4 +32,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - keep_symlinks: True - force_symlinks: True +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-pgp.sls b/copy-pgp.sls index 4c4461d..608b82d 100644 --- a/copy-pgp.sls +++ b/copy-pgp.sls @@ -28,4 +28,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - user: root - group: root +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-sh.sls b/copy-sh.sls index a1273a2..02d4b7c 100644 --- a/copy-sh.sls +++ b/copy-sh.sls @@ -48,4 +48,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - recurse: - mode +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-ssh.sls b/copy-ssh.sls index 042756a..0ef30db 100644 --- a/copy-ssh.sls +++ b/copy-ssh.sls @@ -29,4 +29,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - user: root - group: root +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-tmux.sls b/copy-tmux.sls index b87ecbd..fe32fc6 100644 --- a/copy-tmux.sls +++ b/copy-tmux.sls @@ -42,4 +42,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - recurse: - mode +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-vim.sls b/copy-vim.sls index 2e1da3d..2c9d268 100644 --- a/copy-vim.sls +++ b/copy-vim.sls @@ -28,4 +28,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - user: root - group: root +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-x11.sls b/copy-x11.sls index 91a1eb8..ea7f33a 100644 --- a/copy-x11.sls +++ b/copy-x11.sls @@ -32,4 +32,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - keep_symlinks: True - force_symlinks: True +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} diff --git a/copy-xfce.sls b/copy-xfce.sls index fe15a09..56b0f06 100644 --- a/copy-xfce.sls +++ b/copy-xfce.sls @@ -32,4 +32,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later - keep_symlinks: True - force_symlinks: True +{%- else -%} + +"{{ sls }}-is-deactivated": + test.nop + {%- endif %} From a42cd5c13033fa0ff1915ae5da01b9df8fc60c36 Mon Sep 17 00:00:00 2001 From: seven beep Date: Mon, 14 Oct 2024 20:58:41 +0200 Subject: [PATCH 3/5] fix: include on copy-all and more versatile blacklisting/whitelisting Jinja around the includes was refined to take care of more specific setups where an user could have disabled all dotfiles but is enabling some specifically, whether by whitelisting or blacklisting. --- copy-all.sls | 15 ++++++++++++++- copy-dom0.sls | 7 +++++-- copy-git.sls | 7 +++++-- copy-gtk.sls | 7 +++++-- copy-mutt.sls | 7 +++++-- copy-net.sls | 7 +++++-- copy-pgp.sls | 7 +++++-- copy-sh.sls | 7 +++++-- copy-ssh.sls | 7 +++++-- copy-tmux.sls | 7 +++++-- copy-vim.sls | 7 +++++-- copy-x11.sls | 7 +++++-- copy-xfce.sls | 7 +++++-- 13 files changed, 74 insertions(+), 25 deletions(-) diff --git a/copy-all.sls b/copy-all.sls index be8d97d..6f355ab 100644 --- a/copy-all.sls +++ b/copy-all.sls @@ -5,7 +5,20 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if salt['pillar.get']('qusal:dotfiles:all', default=true) == true -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:dom0') == true + or salt['pillar.get']('qusal:dotfiles:git') == true + or salt['pillar.get']('qusal:dotfiles:gtk') == true + or salt['pillar.get']('qusal:dotfiles:net') == true + or salt['pillar.get']('qusal:dotfiles:pgp') == true + or salt['pillar.get']('qusal:dotfiles:sh') == true + or salt['pillar.get']('qusal:dotfiles:ssh') == true + or salt['pillar.get']('qusal:dotfiles:vim') == true + or salt['pillar.get']('qusal:dotfiles:x11') == true + or salt['pillar.get']('qusal:dotfiles:xfce') == true + ) +-%} include: - .copy-dom0 diff --git a/copy-dom0.sls b/copy-dom0.sls index c71a7d2..3c44cab 100644 --- a/copy-dom0.sls +++ b/copy-dom0.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:dom0', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:dom0') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-git.sls b/copy-git.sls index 7c86521..5676901 100644 --- a/copy-git.sls +++ b/copy-git.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:git', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:git') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-gtk.sls b/copy-gtk.sls index 699112b..fe8120d 100644 --- a/copy-gtk.sls +++ b/copy-gtk.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:gtk', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:gtk') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-mutt.sls b/copy-mutt.sls index 1df8af0..e10efe3 100644 --- a/copy-mutt.sls +++ b/copy-mutt.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:mutt', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:mutt') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-net.sls b/copy-net.sls index 40e7294..3228f06 100644 --- a/copy-net.sls +++ b/copy-net.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:net', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:net') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-pgp.sls b/copy-pgp.sls index 608b82d..a8965f7 100644 --- a/copy-pgp.sls +++ b/copy-pgp.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:gpg', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:pgp') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-sh.sls b/copy-sh.sls index 02d4b7c..2e80613 100644 --- a/copy-sh.sls +++ b/copy-sh.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:sh', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:sh') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-ssh.sls b/copy-ssh.sls index 0ef30db..327255c 100644 --- a/copy-ssh.sls +++ b/copy-ssh.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:ssh', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:ssh') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-tmux.sls b/copy-tmux.sls index fe32fc6..e503243 100644 --- a/copy-tmux.sls +++ b/copy-tmux.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:tmux', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:tmux') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-vim.sls b/copy-vim.sls index 2c9d268..36b587e 100644 --- a/copy-vim.sls +++ b/copy-vim.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:vim', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:vim') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-x11.sls b/copy-x11.sls index ea7f33a..499f190 100644 --- a/copy-x11.sls +++ b/copy-x11.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:x11', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:x11') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} diff --git a/copy-xfce.sls b/copy-xfce.sls index 56b0f06..8c257a7 100644 --- a/copy-xfce.sls +++ b/copy-xfce.sls @@ -5,8 +5,11 @@ SPDX-FileCopyrightText: 2024 seven-beep SPDX-License-Identifier: AGPL-3.0-or-later #} -{%- if ( (salt['pillar.get']('qusal:dotfiles:all', default=true) == true ) - and (salt['pillar.get']('qusal:dotfiles:xfce', default=true) == true )) -%} +{%- if ( + salt['pillar.get']('qusal:dotfiles:all', default=true) == true + or salt['pillar.get']('qusal:dotfiles:xfce') == true + ) +-%} {%- import "dom0/gui-user.jinja" as gui_user -%} From 3cb9a049612f8e747358e16b4d577b60f1228f13 Mon Sep 17 00:00:00 2001 From: seven beep Date: Mon, 14 Oct 2024 20:51:19 +0200 Subject: [PATCH 4/5] feat: provide example pillar files --- pillar.sls.example | 48 ++++++++++++++++++++++++++++++++++++++++++++++ pillar.top.example | 19 ++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 pillar.sls.example create mode 100644 pillar.top.example diff --git a/pillar.sls.example b/pillar.sls.example new file mode 100644 index 0000000..498a4c3 --- /dev/null +++ b/pillar.sls.example @@ -0,0 +1,48 @@ +{# +SPDX-FileCopyrightText: 2024 seven-beep + +SPDX-License-Identifier: CC-BY-SA-4.0 +#} +{# + +Example of a pillar state structure for https://github.com/ben-grande/dotfiles + +This file need to be placed in your pillar_roots, renamed with a '.sls' +extension and referenced by a top file. See 'pillar.top.example' for an example +and the README for instructions. + +Each entry in the pillar state is optional. You can disable the entire dotfile +setup by keeping only 'qusal:dotfiles:all' to 'false', or selectively disable +individual components by setting 'false' for the corresponding state entries. + +#} + +qusal: + dotfiles: + # Control whether or not applying the copy-all.sls or any other dotfiles states. + # Disabling it will disable all states, unless some are specifically whitelisted. + all: true + # Control whether or not applying the copy-x11.sls state. + dom0: true + # Control whether or not applying the copy-dom0.sls state. + git: true + # Control whether or not applying the copy-git.sls state. + gtk: true + # Control whether or not applying the copy-gtk.sls state. + mutt: true + # Control whether or not applying the copy-mutt.sls state. + net: true + # Control whether or not applying the copy-net.sls state. + pgp: true + # Control whether or not applying the copy-pgp.sls state. + sh: true + # Control whether or not applying the copy-sh.sls state. + ssh: true + # Control whether or not applying the copy-ssh.sls state. + tmux: true + # Control whether or not applying the copy-tmux.sls state. + vim: true + # Control whether or not applying the copy-vim.sls state. + x11: true + # Control whether or not applying the copy-x11.sls state. + xfce: true diff --git a/pillar.top.example b/pillar.top.example new file mode 100644 index 0000000..686b7ab --- /dev/null +++ b/pillar.top.example @@ -0,0 +1,19 @@ +{# +SPDX-FileCopyrightText: 2024 seven-beep + +SPDX-License-Identifier: CC-BY-SA-4.0 +#} +{# + +Example of a pillar top structure for https://github.com/ben-grande/dotfiles + +This file need to be placed in your pillar_roots, renamed with a '.top' +extension, to refer to a valid pillar state file and enabled with 'qubectl +top.enable'. See 'pillar.sls.example' for an example and the README for +instructions. + +#} + +base: + '*': + - qusal.dotfiles From 540aa583c9fbcbbbc49e322744627b3301a3568a Mon Sep 17 00:00:00 2001 From: seven beep Date: Mon, 14 Oct 2024 20:51:55 +0200 Subject: [PATCH 5/5] fix: mention to example files and wording --- README.md | 23 +++++++++++------------ pillar.sls.example | 23 +++++++---------------- pillar.top.example | 4 ++-- 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index d350f69..fe5bc65 100644 --- a/README.md +++ b/README.md @@ -63,18 +63,15 @@ sudo qubesctl state.apply dotfiles.copy-dom0,dotfiles.copy-sh,dotfiles.copy-vim, #### Pillar -With salt, each state execution can be opt out by topic via a corresponding -pillar set to a non true value (eg: Setting qusal:dotfiles:dom0 to false will -disable states specific to dom0, setting qusal:dotfiles:git to false will -disable states specific to git). +By default, all states are executed when applied. This can be deactivated in +full or in part by configuring the corresponding pillar data to a non true +value. You will need a top file and a sls file in your pillar_roots, when following [the Qusal's installation instructions](https://github.com/ben-grande/qusal/blob/main/docs/INSTALL.md), `/srv/pillar/qusal` will be added to you pillar_roots. -By default, the formulas assume that you opt-in for all dotfiles. - -Example: /srv/pillar/qusal/dotfiles.top: +Example: `/srv/pillar/qusal/dotfiles.top` ```yaml base: @@ -82,10 +79,9 @@ base: - qusal.dotfiles ``` -It will apply the qusal/dotfiles sls to all targets. +It will apply the `qusal/dotfiles.sls` on all targets. -Example: /srv/pillar/qusal/dotfiles.sls containing the data to pass to the -targets: +Example: `/srv/pillar/qusal/dotfiles.sls`: ```yaml qusal: @@ -93,7 +89,10 @@ qusal: dom0: false ``` -It will disable the dom0 dotfiles configuration. +This will disable the dom0 dotfiles configuration. + +For a complete example of a pillar state and a listing of their corresponding +formulas states, please refer to `pillar.sls.example`. Enable the pillar top above: @@ -101,7 +100,7 @@ Enable the pillar top above: sudo qubesctl top.enable qusal.dotfiles pillar=true ``` -Now subsequent calls to the states of this repository will skip copy-dom0. +Now subsequent calls to the states of this repository will skip `copy-dom0.sls`. ### Script diff --git a/pillar.sls.example b/pillar.sls.example index 498a4c3..e966dfe 100644 --- a/pillar.sls.example +++ b/pillar.sls.example @@ -12,37 +12,28 @@ extension and referenced by a top file. See 'pillar.top.example' for an example and the README for instructions. Each entry in the pillar state is optional. You can disable the entire dotfile -setup by keeping only 'qusal:dotfiles:all' to 'false', or selectively disable -individual components by setting 'false' for the corresponding state entries. +setup by keeping *only* 'qusal:dotfiles:all' to 'false', or selectively +disabling individual components by setting 'false' for the corresponding state +entries (eg: 'dom0' correspond to 'copy-dom0.sls'). + +Alternatively you can keep 'qusal:dotfiles:all' to 'true' and selectively +enabling individual components by setting 'true' for the corresponding state +entries. #} qusal: dotfiles: - # Control whether or not applying the copy-all.sls or any other dotfiles states. - # Disabling it will disable all states, unless some are specifically whitelisted. all: true - # Control whether or not applying the copy-x11.sls state. dom0: true - # Control whether or not applying the copy-dom0.sls state. git: true - # Control whether or not applying the copy-git.sls state. gtk: true - # Control whether or not applying the copy-gtk.sls state. mutt: true - # Control whether or not applying the copy-mutt.sls state. net: true - # Control whether or not applying the copy-net.sls state. pgp: true - # Control whether or not applying the copy-pgp.sls state. sh: true - # Control whether or not applying the copy-sh.sls state. ssh: true - # Control whether or not applying the copy-ssh.sls state. tmux: true - # Control whether or not applying the copy-tmux.sls state. vim: true - # Control whether or not applying the copy-vim.sls state. x11: true - # Control whether or not applying the copy-x11.sls state. xfce: true diff --git a/pillar.top.example b/pillar.top.example index 686b7ab..97fe753 100644 --- a/pillar.top.example +++ b/pillar.top.example @@ -7,8 +7,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0 Example of a pillar top structure for https://github.com/ben-grande/dotfiles -This file need to be placed in your pillar_roots, renamed with a '.top' -extension, to refer to a valid pillar state file and enabled with 'qubectl +This file needs to be placed in your pillar_roots, renamed with a '.top' +extension, to refer to a valid pillar state file and enabled with 'qubesctl top.enable'. See 'pillar.sls.example' for an example and the README for instructions.