From 25ed38ead8f4059ad80763585199be3b477309b5 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Fri, 9 Dec 2022 23:47:57 +0100 Subject: [PATCH] updated openvpn_server state --- states/openvpn_server/config.sls | 12 +++++++++++- states/openvpn_server/map.jinja | 14 +++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/states/openvpn_server/config.sls b/states/openvpn_server/config.sls index 636f0e7..a0baf3f 100644 --- a/states/openvpn_server/config.sls +++ b/states/openvpn_server/config.sls @@ -1,5 +1,6 @@ --- {%- from "openvpn_server/map.jinja" import openvpn_server with context %} +{%- from "openvpn_client/map.jinja" import openvpn_client with context %} {%- for key, instance in openvpn_server.config.items() %} openvpn-server-{{ key }}-config: file.managed: @@ -24,4 +25,13 @@ openvpn-server-{{ key }}-config: dns: {{ instance.dns }} - watch_in: - service: openvpn-server-{{ key }}-service -{%- endfor %} + +{% for user in openvpn_client.config[key].remote_hosts -%} +openvpn-server-user-{{ user.name }}: + user.present: + - name: {{ user.name }} + - password: {{ user.password }} + - hash_password: true + - shell: /sbin/nologin +{% endfor -%} +{%- endfor %} diff --git a/states/openvpn_server/map.jinja b/states/openvpn_server/map.jinja index d4fed6d..4db5e2c 100644 --- a/states/openvpn_server/map.jinja +++ b/states/openvpn_server/map.jinja @@ -1,8 +1,12 @@ -{%- import_yaml "openvpn_server/defaults.yaml" as defaults %} +{%- import_yaml "openvpn_server/defaults.yaml" as server %} +{%- import_yaml "openvpn_client/defaults.yaml" as client %} {%- set openvpn_server = salt['pillar.get']( 'openvpn_server', - default=defaults.openvpn_server, - merge=True - ) --%} \ No newline at end of file + default=server.openvpn_server, + merge=True) -%} + +{%- set openvpn_client = salt['pillar.get']( + 'openvpn_client', + default=client.openvpn_client, + merge=True) -%} \ No newline at end of file