From b01f2d213a599e75a60707a1e862c97f89bc84cd Mon Sep 17 00:00:00 2001 From: Ben Grande Date: Mon, 29 Jan 2024 12:11:51 +0100 Subject: [PATCH] chore: move port forward to dom0 formula The script can be used with sys-cacher, sys-pihole, sys-syncthing, sys-ssh and many services you'd want to forward, make it reusable. --- .../files/bin}/qvm-port-forward | 0 salt/dom0/init.sls | 1 + salt/dom0/port-forward.sls | 18 ++++++++++++++++++ salt/dom0/port-forward.top | 10 ++++++++++ salt/sys-syncthing/create.sls | 10 +--------- 5 files changed, 30 insertions(+), 9 deletions(-) rename salt/{sys-syncthing/files/admin/firewall => dom0/files/bin}/qvm-port-forward (100%) create mode 100644 salt/dom0/port-forward.sls create mode 100644 salt/dom0/port-forward.top diff --git a/salt/sys-syncthing/files/admin/firewall/qvm-port-forward b/salt/dom0/files/bin/qvm-port-forward similarity index 100% rename from salt/sys-syncthing/files/admin/firewall/qvm-port-forward rename to salt/dom0/files/bin/qvm-port-forward diff --git a/salt/dom0/init.sls b/salt/dom0/init.sls index 9043ff9..a6a8211 100644 --- a/salt/dom0/init.sls +++ b/salt/dom0/init.sls @@ -8,6 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later include: - .install + - .port-forward - .backup - .xorg - .kde diff --git a/salt/dom0/port-forward.sls b/salt/dom0/port-forward.sls new file mode 100644 index 0000000..665d5e2 --- /dev/null +++ b/salt/dom0/port-forward.sls @@ -0,0 +1,18 @@ +{# +SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. + +SPDX-License-Identifier: AGPL-3.0-or-later +#} + +{% if grains['nodename'] == 'dom0' -%} + +"{{ slsdotpath }}-port-forward-script": + file.managed: + - name: /usr/local/bin/qvm-port-forward + - source: salt://{{ slsdotpath }}/files/bin/qvm-port-forward + - mode: "0755" + - user: root + - group: root + - makedirs: True + +{% endif -%} diff --git a/salt/dom0/port-forward.top b/salt/dom0/port-forward.top new file mode 100644 index 0000000..578ace6 --- /dev/null +++ b/salt/dom0/port-forward.top @@ -0,0 +1,10 @@ +{# +SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. + +SPDX-License-Identifier: AGPL-3.0-or-later +#} + +base: + 'dom0': + - match: nodegroup + - dom0.port-forward diff --git a/salt/sys-syncthing/create.sls b/salt/sys-syncthing/create.sls index 0a5a81e..7ee30b0 100644 --- a/salt/sys-syncthing/create.sls +++ b/salt/sys-syncthing/create.sls @@ -10,6 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later include: - .clone - browser.create + - dom0.port-forward {% load_yaml as defaults -%} name: tpl-{{ slsdotpath }} @@ -100,12 +101,3 @@ features: {% from 'utils/macros/policy.sls' import policy_set with context -%} {{ policy_set(sls_path, '80') }} - -"{{ slsdotpath }}-qvm-port-forward": - file.managed: - - name: /usr/local/bin/qvm-port-forward - - source: salt://{{ slsdotpath }}/files/admin/firewall/qvm-port-forward - - user: root - - group: root - - mode: '0755' - - makedirs: True