Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow to exclude dotfiles on pillar data #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 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,47 @@ Install specific files in Dom0:
sudo qubesctl state.apply dotfiles.copy-dom0,dotfiles.copy-sh,dotfiles.copy-vim,dotfiles.copy-x11
```

#### Pillar

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.

Example: `/srv/pillar/qusal/dotfiles.top`

```yaml
base:
'*':
- qusal.dotfiles
```

It will apply the `qusal/dotfiles.sls` on all targets.

Example: `/srv/pillar/qusal/dotfiles.sls`:

```yaml
qusal:
dotfiles:
dom0: false
```

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:

```sh
sudo qubesctl top.enable qusal.dotfiles pillar=true
```

Now subsequent calls to the states of this repository will skip `copy-dom0.sls`.

### Script

You can simply deploy all configurations with:
Expand Down
23 changes: 23 additions & 0 deletions copy-all.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
{#
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
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
- .copy-git
Expand All @@ -17,6 +33,13 @@ include:
- .copy-x11
- .copy-xfce

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- 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
14 changes: 14 additions & 0 deletions copy-dom0.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{#
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
or salt['pillar.get']('qusal:dotfiles:dom0') == true
)
-%}

{%- import "dom0/gui-user.jinja" as gui_user -%}

"{{ slsdotpath }}-copy-dom0-home":
Expand All @@ -25,3 +32,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- user: root
- group: root
- makedirs: True

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif %}
14 changes: 14 additions & 0 deletions copy-git.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{#
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
or salt['pillar.get']('qusal:dotfiles:git') == true
)
-%}

{%- import "dom0/gui-user.jinja" as gui_user -%}

"{{ slsdotpath }}-copy-git-home":
Expand Down Expand Up @@ -65,3 +72,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- mode: '0755'
- recurse:
- mode

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif %}
14 changes: 14 additions & 0 deletions copy-gtk.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{#
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
or salt['pillar.get']('qusal:dotfiles:gtk') == true
)
-%}

{%- import "dom0/gui-user.jinja" as gui_user -%}

"{{ slsdotpath }}-copy-gtk-home":
Expand All @@ -23,3 +30,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif %}
14 changes: 14 additions & 0 deletions copy-mutt.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{#
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
or salt['pillar.get']('qusal:dotfiles:mutt') == true
)
-%}

{%- import "dom0/gui-user.jinja" as gui_user -%}

"{{ slsdotpath }}-copy-mutt-home":
Expand All @@ -25,3 +32,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- user: root
- group: root
- makedirs: True

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif %}
14 changes: 14 additions & 0 deletions copy-net.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{#
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
or salt['pillar.get']('qusal:dotfiles:net') == true
)
-%}

{%- import "dom0/gui-user.jinja" as gui_user -%}

"{{ slsdotpath }}-copy-net-home":
Expand All @@ -27,3 +34,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- group: root
- keep_symlinks: True
- force_symlinks: True

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif %}
14 changes: 14 additions & 0 deletions copy-pgp.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{#
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
or salt['pillar.get']('qusal:dotfiles:pgp') == true
)
-%}

{%- import "dom0/gui-user.jinja" as gui_user -%}

"{{ slsdotpath }}-copy-pgp-home":
Expand All @@ -23,3 +30,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif %}
14 changes: 14 additions & 0 deletions copy-sh.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{#
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
or salt['pillar.get']('qusal:dotfiles:sh') == true
)
-%}

{%- import "dom0/gui-user.jinja" as gui_user -%}

"{{ slsdotpath }}-copy-sh-home":
Expand Down Expand Up @@ -43,3 +50,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0755'
- recurse:
- mode

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif %}
14 changes: 14 additions & 0 deletions copy-ssh.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{#
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
or salt['pillar.get']('qusal:dotfiles:ssh') == true
)
-%}

{%- import "dom0/gui-user.jinja" as gui_user -%}

"{{ slsdotpath }}-copy-ssh-home":
Expand All @@ -24,3 +31,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif %}
14 changes: 14 additions & 0 deletions copy-tmux.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{#
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
or salt['pillar.get']('qusal:dotfiles:tmux') == true
)
-%}

{%- import "dom0/gui-user.jinja" as gui_user -%}

"{{ slsdotpath }}-copy-tmux-home":
Expand Down Expand Up @@ -37,3 +44,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- mode: '0755'
- recurse:
- mode

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif %}
14 changes: 14 additions & 0 deletions copy-vim.sls
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{#
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
or salt['pillar.get']('qusal:dotfiles:vim') == true
)
-%}

{%- import "dom0/gui-user.jinja" as gui_user -%}

"{{ slsdotpath }}-copy-vim-home":
Expand All @@ -23,3 +30,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- dir_mode: '0700'
- user: root
- group: root

{%- else -%}

"{{ sls }}-is-deactivated":
test.nop

{%- endif %}
Loading