You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
---
|
|
|
|
|
|
|
|
- name: Install required packages
|
|
|
|
apt:
|
|
|
|
state: present
|
|
|
|
name:
|
|
|
|
- sudo
|
|
|
|
|
|
|
|
- name: Create new user {{ bootstrap_expected_user }}
|
|
|
|
user:
|
|
|
|
state: present
|
|
|
|
name: "{{ bootstrap_expected_user }}"
|
|
|
|
groups:
|
|
|
|
- sudo
|
|
|
|
append: yes
|
|
|
|
password: "{{ bootstrap_expected_become_pass | password_hash('sha512', LOCAL_SALT) }}"
|
|
|
|
update_password: on_create
|
|
|
|
register: bootstrap_expected_user_data
|
|
|
|
|
|
|
|
- name: Copy SSH Keys if bootstraped now
|
|
|
|
when: bootstrap_used
|
|
|
|
block:
|
|
|
|
- name: Retrieve data from user {{ bootstrap_user }}
|
|
|
|
user:
|
|
|
|
name: "{{ bootstrap_user }}"
|
|
|
|
state: present
|
|
|
|
register: bootstrap_user_data
|
|
|
|
- name: Create .ssh directory for user {{ bootstrap_expected_user }}
|
|
|
|
file:
|
|
|
|
path: "{{ bootstrap_expected_user_data.home }}/.ssh"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ bootstrap_expected_user }}"
|
|
|
|
group: "{{ bootstrap_expected_user }}"
|
|
|
|
become: yes
|
|
|
|
- name: Transfer SSH keys to new user
|
|
|
|
copy:
|
|
|
|
remote_src: yes
|
|
|
|
src: "{{ bootstrap_user_data.home }}/.ssh/authorized_keys"
|
|
|
|
dest: "{{ bootstrap_expected_user_data.home }}/.ssh/authorized_keys"
|
|
|
|
owner: "{{ bootstrap_expected_user }}"
|
|
|
|
group: "{{ bootstrap_expected_user }}"
|
|
|
|
mode: u=rw,g=r,o=
|
|
|
|
become: yes
|