From 41dfd44f1520728da65e43abc6fddfb59b2fed78 Mon Sep 17 00:00:00 2001 From: nicoo Date: Wed, 15 Nov 2017 01:43:33 +0100 Subject: [PATCH] ansible/roles/base: Light refactoring --- ansible/roles/base/tasks/main.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ansible/roles/base/tasks/main.yaml b/ansible/roles/base/tasks/main.yaml index 1e53273..c62d223 100644 --- a/ansible/roles/base/tasks/main.yaml +++ b/ansible/roles/base/tasks/main.yaml @@ -1,4 +1,9 @@ --- +- set_fact: + sshd_allowusers: >- + {{ [ 'root' ] | union(sshd_allowusers_group | default([])) + | union(sshd_allowusers_host | default([])) }} + - name: only allow pubkey auth for root lineinfile: dest: /etc/ssh/sshd_config @@ -10,7 +15,7 @@ lineinfile: dest: /etc/ssh/sshd_config regexp: "^#?AllowUsers" - line: "AllowUsers {{ ' '.join([ 'root' ] | union(sshd_allowusers_group | default([])) | union(sshd_allowusers_host | default([]))) }}" + line: "AllowUsers {{ ' '.join(sshd_allowusers) }}" when: sshd_allowusers_set is defined and sshd_allowgroup is not defined notify: restart ssh @@ -32,7 +37,7 @@ name: "{{ item }}" groups: "{{ sshd_allowgroup }}" append: True - with_items: "{{ [ 'root' ] | union(sshd_allowusers_group | default([])) | union(sshd_allowusers_host | default([])) }}" + with_items: "{{ sshd_allowusers }}" when: sshd_allowgroup is defined -- 1.7.10.4