Skip to content

Commit

Permalink
feat: Allow to exclude dotfiles on pillar data
Browse files Browse the repository at this point in the history
  • Loading branch information
seven-beep committed Sep 20, 2024
1 parent 7e2502b commit f827d1b
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<!--
SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>
SPDX-License-Identifier: CC-BY-SA-4.0
-->
Expand All @@ -13,6 +14,7 @@ Dotfiles.
* [Description](#description)
* [Installation](#installation)
* [Salt](#salt)
* [Pillar](#pillar)
* [Script](#script)
* [Usage](#usage)
* [License](#license)
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions copy-all.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{#
SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

SPDX-License-Identifier: AGPL-3.0-or-later
#}

{%- if salt['pillar.get']('qusal:dotfiles:all', default=true) == true -%}

include:
- .copy-dom0
- .copy-git
Expand All @@ -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'.
Expand Down
6 changes: 6 additions & 0 deletions copy-dom0.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand All @@ -25,3 +29,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- user: root
- group: root
- makedirs: True
{%- endif %}
6 changes: 6 additions & 0 deletions copy-git.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand Down Expand Up @@ -65,3 +69,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- mode: '0755'
- recurse:
- mode
{%- endif %}
6 changes: 6 additions & 0 deletions copy-gtk.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand All @@ -23,3 +27,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root
{%- endif %}
6 changes: 6 additions & 0 deletions copy-mutt.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand All @@ -25,3 +29,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- user: root
- group: root
- makedirs: True
{%- endif %}
6 changes: 6 additions & 0 deletions copy-net.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand All @@ -27,3 +31,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root
- keep_symlinks: True
- force_symlinks: True
{%- endif %}
6 changes: 6 additions & 0 deletions copy-pgp.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand All @@ -23,3 +27,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root
{%- endif %}
6 changes: 6 additions & 0 deletions copy-sh.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand Down Expand Up @@ -43,3 +47,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0755'
- recurse:
- mode
{%- endif %}
6 changes: 6 additions & 0 deletions copy-ssh.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand All @@ -24,3 +28,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root
{%- endif %}
6 changes: 6 additions & 0 deletions copy-tmux.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand Down Expand Up @@ -37,3 +41,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- mode: '0755'
- recurse:
- mode
{%- endif %}
6 changes: 6 additions & 0 deletions copy-vim.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand All @@ -23,3 +27,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root
{%- endif %}
6 changes: 6 additions & 0 deletions copy-x11.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand All @@ -27,3 +31,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root
- keep_symlinks: True
- force_symlinks: True
{%- endif %}
6 changes: 6 additions & 0 deletions copy-xfce.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{#
SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <[email protected]>
SPDX-FileCopyrightText: 2024 seven-beep <[email protected]>

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":
Expand All @@ -27,3 +31,5 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root
- keep_symlinks: True
- force_symlinks: True
{%- endif %}

0 comments on commit f827d1b

Please sign in to comment.