You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
534 B
19 lines
534 B
2 years ago
|
---
|
||
|
# This playbook creates a sudo-enabled user matching the execution user's name.
|
||
|
|
||
|
- name: create new user
|
||
|
ansible.builtin.user:
|
||
|
name: "{{ username }}"
|
||
|
groups:
|
||
|
- sudo
|
||
|
append: yes
|
||
|
|
||
|
# Required to prevent user lockout because PAM will be disabled
|
||
|
- name: set impossible password for user
|
||
|
ansible.builtin.command: "usermod -p '*' {{ username }}"
|
||
|
|
||
|
- name: copy ssh public key from host
|
||
|
ansible.posix.authorized_key:
|
||
|
user: "{{ username }}"
|
||
|
key: "{{ lookup('file', '/home/{{username}}/.ssh/id_rsa.pub') }}"
|