2018-08-26 13:10:15 +00:00
|
|
|
|
2018-10-02 17:38:23 +00:00
|
|
|
- name: Ensure .ssh folder is created | Debian/Ubuntu systems
|
2018-08-13 14:02:31 +00:00
|
|
|
file:
|
|
|
|
path: "/home/{{item.name}}/.ssh"
|
|
|
|
state: directory
|
2018-08-15 18:35:23 +00:00
|
|
|
mode: 0700
|
|
|
|
owner: "{{ item.name }}"
|
|
|
|
group: "{{ item.name }}"
|
2018-08-13 14:02:31 +00:00
|
|
|
with_items:
|
|
|
|
- "{{ users }}"
|
2018-10-09 00:32:45 +00:00
|
|
|
when: item.state == "present" and item.name != 'ec2-user' and ansible_os_family == 'Debian'
|
2018-08-13 14:02:31 +00:00
|
|
|
|
|
|
|
|
2018-10-02 17:38:23 +00:00
|
|
|
- name: Configure authorized_keys | Debian/Ubuntu systems
|
2018-08-15 18:35:23 +00:00
|
|
|
authorized_key:
|
|
|
|
user: "{{ item.0.name }}"
|
|
|
|
key: "{{ lookup('file', 'keys/' + item.0.name + '/' + item.1.file + '.pub') }}"
|
|
|
|
state: "{{ item.1.state | default('present') }}"
|
|
|
|
with_subelements:
|
|
|
|
- "{{ users }}"
|
|
|
|
- keys
|
2018-10-09 00:32:45 +00:00
|
|
|
when: item.0.state is defined and item.0.state == "present" and item.0.name != 'ec2-user' and ansible_os_family == 'Debian'
|
2018-08-15 18:35:23 +00:00
|
|
|
|
2018-10-02 17:38:23 +00:00
|
|
|
- name: Ensure .ssh folder is created | FreeBSD systems
|
|
|
|
file:
|
|
|
|
path: "/home/{{item.name}}/.ssh"
|
|
|
|
state: directory
|
|
|
|
mode: 0700
|
|
|
|
owner: "{{ item.name }}"
|
|
|
|
group: "{{ item.name }}"
|
|
|
|
with_items:
|
|
|
|
- "{{ users }}"
|
|
|
|
when: item.state == "present" and item.name != 'ubuntu' and ansible_os_family == 'FreeBSD'
|
|
|
|
|
|
|
|
|
|
|
|
- name: Configure authorized_keys | FreeBSD systems
|
|
|
|
authorized_key:
|
|
|
|
user: "{{ item.0.name }}"
|
|
|
|
key: "{{ lookup('file', 'keys/' + item.0.name + '/' + item.1.file + '.pub') }}"
|
|
|
|
state: "{{ item.1.state | default('present') }}"
|
|
|
|
with_subelements:
|
|
|
|
- "{{ users }}"
|
|
|
|
- keys
|
|
|
|
when: item.0.state is defined and item.0.state == "present" and item.0.name != 'ubuntu' and ansible_os_family == 'FreeBSD'
|