diff --git a/states/openvpn_client/config.sls b/states/openvpn_client/config.sls index bcdd608..fa8e593 100644 --- a/states/openvpn_client/config.sls +++ b/states/openvpn_client/config.sls @@ -1,8 +1,8 @@ --- -{%- from "openvpn_client/map.jinja" import openvpn with context %} +{%- from "openvpn_client/map.jinja" import openvpn_client with context %} openvpn-client-main-config: file.managed: - - name: {{ openvpn.config_dir }}/vpn.conf + - name: {{ openvpn_client.config_dir }}/vpn.conf - source: salt://openvpn_client/vpn.conf.j2 - user: root - group: root @@ -13,7 +13,7 @@ openvpn-client-main-config: openvpn-client-private-dir: file.directory: - - name: {{ openvpn.config_dir }}/vpn + - name: {{ openvpn_client.config_dir }}/private - user: root - group: root - mode: 0700 @@ -22,11 +22,11 @@ openvpn-client-private-dir: openvpn-client-private-access: file.managed: - - name: {{ openvpn.config_dir }}/vpn/pass + - name: {{ openvpn_client.config_dir }}/private/pass - source: salt://openvpn_client/pass.j2 - template: jinja - user: root - group: root - mode: 0600 - watch_in: - - service: openvpn-client-service \ No newline at end of file + - service: openvpn-client-service diff --git a/states/openvpn_client/defaults.yaml b/states/openvpn_client/defaults.yaml index ea016a4..f633d44 100644 --- a/states/openvpn_client/defaults.yaml +++ b/states/openvpn_client/defaults.yaml @@ -1,3 +1,3 @@ --- -openvpn: +openvpn_client: config_dir: /etc/openvpn diff --git a/states/openvpn_client/map.jinja b/states/openvpn_client/map.jinja index d9f068b..4a09c30 100644 --- a/states/openvpn_client/map.jinja +++ b/states/openvpn_client/map.jinja @@ -1,5 +1,5 @@ {%- import_yaml "openvpn_client/defaults.yaml" as default_settings -%} -{%- set defaults = salt['grains.filter_by'](default_settings, default='openvpn') -%} +{%- set defaults = salt['grains.filter_by'](default_settings, default='openvpn_client') -%} -{%- set openvpn = salt['pillar.get']('openvpn', default=defaults, merge=True) -%} \ No newline at end of file +{%- set openvpn_client = salt['pillar.get']('openvpn_client', default=defaults, merge=True) -%} diff --git a/states/openvpn_client/pass.j2 b/states/openvpn_client/pass.j2 index a586a3e..adff34d 100644 --- a/states/openvpn_client/pass.j2 +++ b/states/openvpn_client/pass.j2 @@ -1,7 +1,7 @@ -{%- from "openvpn_client/map.jinja" import openvpn with context -%} -{%- for client in openvpn.config.vpn.remote_hosts -%} +{%- from "openvpn_client/map.jinja" import openvpn_client with context -%} +{%- for client in openvpn_client.config.vpn.remote_hosts -%} {%- if client.name == salt['grains.get']('host') -%} {{ client.name }} {{ client.password }} {%- endif -%} -{%- endfor -%} \ No newline at end of file +{%- endfor -%} diff --git a/states/openvpn_client/vpn.conf.j2 b/states/openvpn_client/vpn.conf.j2 index aea637b..964c391 100644 --- a/states/openvpn_client/vpn.conf.j2 +++ b/states/openvpn_client/vpn.conf.j2 @@ -1,17 +1,17 @@ ## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }} -{%- from "openvpn_client/map.jinja" import openvpn with context %} +{%- from "openvpn_client/map.jinja" import openvpn_client with context %} -{{ openvpn.config.vpn.ca }} +{{ openvpn_client.config.vpn.ca }} -{{ openvpn.config.vpn.cert }} +{{ openvpn_client.config.vpn.cert }} -{{ openvpn.config.vpn.key }} +{{ openvpn_client.config.vpn.key }} client -remote {{ openvpn.config.vpn.global_endpoint_host }} {{ openvpn.config.vpn.global_endpoint_port }} -proto {{ openvpn.config.vpn.global_endpoint_proto }} +remote {{ openvpn_client.config.vpn.global_endpoint_host }} {{ openvpn_client.config.vpn.global_endpoint_port }} +proto {{ openvpn_client.config.vpn.global_endpoint_proto }} dev tun topology subnet @@ -26,4 +26,4 @@ persist-tun compress lzo fast-io -auth-user-pass vpn/pass \ No newline at end of file +auth-user-pass private/pass