- name: "remove the old public ssh key"
file:
- path: /home/{{ item.name }}/.ssh/{{ item.name }}
+ path: /home/{{ item.name }}/.ssh/authorized_keys
state: absent
with_items: "{{ linuxuser | default([]) }}"
- name: "add a new public ssh key"
when: item.state == 'present' and item.public_key != ""
lineinfile:
- path: /home/{{ item.name }}/.ssh/{{ item.name }}
+ path: /home/{{ item.name }}/.ssh/authorized_keys
create: yes
regexp: '.*'
state: "{{ item.state | default('absent') }}"