From f827d1bc7c55a94e6a52459313345e188078e72a Mon Sep 17 00:00:00 2001 From: seven beep Date: Fri, 20 Sep 2024 21:17:50 +0200 Subject: [PATCH] feat: Allow to exclude dotfiles on pillar data --- README.md | 27 +++++++++++++++++++++++++++ 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, 104 insertions(+) diff --git a/README.md b/README.md index 772fa31..52cc6b9 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,31 @@ Install specific files in Dom0: sudo qubesctl state.apply dotfiles.copy-dom0,dotfiles.copy-sh,dotfiles.copy-vim,dotfiles.copy-x11 ``` +#### Pillar + +With Salt, the execution of each state can be opt out via the dotfiles pillar. +You will need a top and a sls file in your pillar_roots (default to /srv/pillar, +/srv/pillar/base, can be configured in /etc/salt/minion.d). + +Exemple: /srv/pillar/qusal/dotfiles.top to apply the dotfiles sls to all targets: +```yaml +base: + '*': + - qusal.dotfiles +``` +Exemple: /srv/pillar/dotfiles.sls containing the data to pass to the targets: +```yaml +qusal: + dotfiles: + all: true # This is the default. use 'false' to disable all states. + dom0: false # Setting dotfiles:dom0 to 'false' will disable copy-dom0 state. +``` +Enable it: +```sh +sudo qubesclt 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..91bf915 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:gpg', 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..7e97284 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:dom0', 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 %}