From 49cfb1229a2ff5f2ff5e3047b09f6aff58dd0652 Mon Sep 17 00:00:00 2001 From: Martin Horak Date: Fri, 3 Aug 2018 14:51:23 +0200 Subject: [PATCH] Accept user.gid settings. Workaround file.directory bug for non-unique uids --- openssh/server/public_key.sls | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/openssh/server/public_key.sls b/openssh/server/public_key.sls index d9fe879..4284ec7 100644 --- a/openssh/server/public_key.sls +++ b/openssh/server/public_key.sls @@ -7,11 +7,21 @@ {%- if user.public_keys is defined %} +{%- if user.user.gid is defined %} +{%- set group = user.user.gid %} +{%- else %} +{%- set group = user.user.name %} +{%- endif %} + {{ user.user.name }}_ssh_dir: file.directory: - name: {{ user.user.home }}/.ssh + {%- if user.user.uid is defined and user.user.uid == 0 %} + - user: root + {%- else %} - user: {{ user.user.name }} - - group: {{ user.user.name }} + {%- endif %} + - group: {{ group }} - mode: 700 {%- if user.get('purge', False) %} @@ -20,7 +30,7 @@ file.managed: - name: {{ user.user.home }}/.ssh/authorized_keys - user: {{ user.user.name }} - - group: {{ user.user.name }} + - group: {{ group }} - mode: 644 - template: jinja - source: salt://openssh/files/authorized_keys