From 26f0f84e7ac9caeb680c9e0a404b6ecbc8cf07a2 Mon Sep 17 00:00:00 2001 From: seven beep Date: Wed, 2 Oct 2024 22:34:07 +0200 Subject: [PATCH] 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. I also refined the jinja2 around the copy-all include to take care of more specific setups where an user could have disabled all dotfiles but is enabling some specifically. --- copy-all.sls | 20 +++++++++++++++++++- 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, 79 insertions(+), 1 deletion(-) diff --git a/copy-all.sls b/copy-all.sls index 719446c..625f286 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 @@ -20,6 +33,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 %}