a0f9b06da9
The bare 'password' variable in user.yml could silently collide with any same-named variable elsewhere in scope. Rename to user_password to namespace it alongside username. BREAKING CHANGE: callers passing 'password' to this role must rename it to user_password.
26 lines
615 B
YAML
Executable File
26 lines
615 B
YAML
Executable File
---
|
|
- name: "Create a new user {{ username }}"
|
|
user:
|
|
name: "{{ username }}"
|
|
password: "{{ user_password | password_hash('sha512') }}"
|
|
groups:
|
|
- sudo
|
|
shell: "{{ shell }}"
|
|
state: present
|
|
append: true
|
|
|
|
- name: Allow sudo to be used without a password
|
|
lineinfile:
|
|
path: /etc/sudoers
|
|
state: present
|
|
regexp: '^%sudo'
|
|
line: '%sudo ALL=(ALL) NOPASSWD: ALL'
|
|
validate: 'visudo -cf %s'
|
|
when: passwordless_sudo | bool
|
|
|
|
- name: Copy over the public SSH key
|
|
authorized_key:
|
|
user: "{{ username }}"
|
|
state: present
|
|
key: "{{ lookup('file', ssh_pubkey_file) }}"
|