Fix: When managing root user, use right dir

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-01-07 18:28:54 +01:00
parent 00916c979c
commit 7fee72eb09
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -12,7 +12,7 @@
- name: Ensure .ssh directory - name: Ensure .ssh directory
file: file:
dest: '/home/{{ item.name }}/.ssh' dest: '{% if item.name != "root" %}/home{% endif %}/{{ item.name }}/.ssh'
state: directory state: directory
mode: 0700 mode: 0700
owner: '{{ item.name }}' owner: '{{ item.name }}'
@ -22,7 +22,7 @@
- name: Install SSH keys for users - name: Install SSH keys for users
copy: copy:
content: '{{ item.ssh_key }}' content: '{{ item.ssh_key }}'
dest: '/home/{{ item.name }}/.ssh/authorized_keys' dest: '{% if item.name != "root" %}/home{% endif %}/{{ item.name }}/.ssh/authorized_keys'
mode: 0600 mode: 0600
owner: '{{ item.name }}' owner: '{{ item.name }}'
group: '{{ item.name }}' group: '{{ item.name }}'
@ -32,7 +32,7 @@
- name: Install Github SSH keys for user - name: Install Github SSH keys for user
get_url: get_url:
url: 'https://github.com/{{ item.github_key_user }}.keys' url: 'https://github.com/{{ item.github_key_user }}.keys'
dest: '/home/{{ item.name }}/.ssh/authorized_keys' dest: '{% if item.name != "root" %}/home{% endif %}/{{ item.name }}/.ssh/authorized_keys'
force: yes force: yes
mode: 0600 mode: 0600
owner: '{{ item.name }}' owner: '{{ item.name }}'