From f281f7c30a5745eb449d5b12415053e9444d699c Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Sun, 5 Feb 2023 18:25:17 +0100 Subject: [PATCH] Torsocks for SUSE logic Signed-off-by: Georg Pfuetzenreuter --- tor/config.sls | 2 +- tor/install.sls | 2 +- tor/map.jinja | 1 + tor/osfamilymap.yaml | 8 +++++++- tor/torsocks.sls | 22 +++++++++++++++++++++- 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/tor/config.sls b/tor/config.sls index 1842265..dea4daa 100644 --- a/tor/config.sls +++ b/tor/config.sls @@ -1,4 +1,4 @@ -{% from "tor/map.jinja" import map with context %} +{% from "tor/map.jinja" import map, osfamily with context %} include: {%- if osfamily == 'Debian' %} diff --git a/tor/install.sls b/tor/install.sls index 494f0b8..96de1e2 100644 --- a/tor/install.sls +++ b/tor/install.sls @@ -1,4 +1,4 @@ -{% from "tor/map.jinja" import map with context %} +{% from "tor/map.jinja" import map, osfamily with context %} {%- if osfamily == 'Debian' %} include: diff --git a/tor/map.jinja b/tor/map.jinja index 1eb8eeb..2733f5e 100644 --- a/tor/map.jinja +++ b/tor/map.jinja @@ -1,5 +1,6 @@ {% import_yaml "tor/defaults.yaml" as defaults %} {% import_yaml "tor/osfamilymap.yaml" as osfamilymap %} +{% set osfamily = salt['grains.get']('os_family', False) %} {% set map = salt['grains.filter_by'](defaults, diff --git a/tor/osfamilymap.yaml b/tor/osfamilymap.yaml index 12bd0f7..fd13ecf 100644 --- a/tor/osfamilymap.yaml +++ b/tor/osfamilymap.yaml @@ -6,4 +6,10 @@ Debian: config_torsocks: '/etc/tor/torsocks.conf' https_support_pkg: apt-transport-https - +Suse: + pkgs: + - tor + service: tor + service_torsocks: torsocks + config_file: '/etc/tor/torrc' + config_torsocks: '/etc/tor/torsocks.conf' diff --git a/tor/torsocks.sls b/tor/torsocks.sls index a6cdff4..b6b01db 100644 --- a/tor/torsocks.sls +++ b/tor/torsocks.sls @@ -1,4 +1,16 @@ -{% from "tor/map.jinja" import map with context %} +{% from "tor/map.jinja" import map, osfamily with context %} + +{%- if osfamily == 'Suse' %} +install_torsocks: + pkg.installed: + - name: torsocks + service.running: + - name: {{ map.service_torsocks }} + - restart: True + - enable: True + - require: + - pkg: install_torsocks +{%- endif %} deploy_tor_torsocks: file.managed: @@ -11,9 +23,17 @@ deploy_tor_torsocks: - defaults: config: {{ map.torsocks }} - require: + {%- if osfamily == 'Suse' %} + - pkg: install_torsocks + {%- else %} - pkg: install_tor + {%- endif %} - watch_in: + {%- if osfamily == 'Suse' %} + - service: install_torsocks + {%- else %} - service: install_tor + {%- endif %}