From 1414cb206a6775fd209ad2c2a0d2c154a1f90b8a Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Sun, 22 Oct 2017 23:24:40 +0000 Subject: [PATCH] handle ssh authorized keys via template --- tasks/main.yml | 4 ++-- templates/ssh_authorized_keys.j2 | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 templates/ssh_authorized_keys.j2 diff --git a/tasks/main.yml b/tasks/main.yml index 2d12541..a912342 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -55,8 +55,8 @@ with_items: "{{ users.keys() }}" - name: ssh authorized keys - copy: - content: "{{ users[item].authorized_keys }}" + template: + src: ssh_authorized_keys.j2 dest: "{{ users[item].home | default('/home/'+item) }}/.ssh/authorized_keys" owner: "{{ item }}" group: "{{ item }}" diff --git a/templates/ssh_authorized_keys.j2 b/templates/ssh_authorized_keys.j2 new file mode 100644 index 0000000..74fcb57 --- /dev/null +++ b/templates/ssh_authorized_keys.j2 @@ -0,0 +1,3 @@ +{% for key in users[item].authorized_keys %} +{{ key }} +{% endfor %}