Compare commits
4
Commits
c413505540
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8984d6368c
|
||
|
|
16a4f97564
|
||
|
|
7f0f540ca3 | ||
|
|
808bb1db4c |
+18
-1
@@ -3,6 +3,11 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
---
|
---
|
||||||
|
- name: Unset password_value fact
|
||||||
|
set_fact:
|
||||||
|
password_value: ""
|
||||||
|
special_pass: false
|
||||||
|
|
||||||
# Handle cases in which password variable is undefined or empty
|
# Handle cases in which password variable is undefined or empty
|
||||||
- name: Disable password login for user unless empty password allowed for user {{ username }}
|
- name: Disable password login for user unless empty password allowed for user {{ username }}
|
||||||
when:
|
when:
|
||||||
@@ -11,6 +16,14 @@
|
|||||||
- not allow_no_password
|
- not allow_no_password
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
password_value: "*"
|
password_value: "*"
|
||||||
|
special_pass: true
|
||||||
|
|
||||||
|
- name: Disable password login because given password was * for user {{ username }}
|
||||||
|
when:
|
||||||
|
- password == "*"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
password_value: "*"
|
||||||
|
special_pass: true
|
||||||
|
|
||||||
- name: Allow login without password as it is explicitely allowed for user {{ username }}
|
- name: Allow login without password as it is explicitely allowed for user {{ username }}
|
||||||
when:
|
when:
|
||||||
@@ -19,13 +32,14 @@
|
|||||||
- allow_no_password
|
- allow_no_password
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
password_value: ""
|
password_value: ""
|
||||||
|
special_pass: true
|
||||||
|
|
||||||
- name: Hash provided password for user {{ username }}
|
- name: Hash provided password for user {{ username }}
|
||||||
when:
|
when:
|
||||||
# Non-empty password has been provided
|
# Non-empty password has been provided
|
||||||
- password is defined
|
- password is defined
|
||||||
# None of the special cases has been handled before
|
# None of the special cases has been handled before
|
||||||
- password_value is not defined
|
- not special_pass
|
||||||
block:
|
block:
|
||||||
- name: Create idempotent salt for password of {{ username }}
|
- name: Create idempotent salt for password of {{ username }}
|
||||||
set_fact:
|
set_fact:
|
||||||
@@ -35,6 +49,7 @@
|
|||||||
ansible.builtin.command: openssl passwd -6 -salt "{{ salt }}" "{{ password }}"
|
ansible.builtin.command: openssl passwd -6 -salt "{{ salt }}" "{{ password }}"
|
||||||
register: username_shadowpw
|
register: username_shadowpw
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
check_mode: false
|
||||||
|
|
||||||
- name: Set password value fact for user {{ username }}
|
- name: Set password value fact for user {{ username }}
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
@@ -48,6 +63,7 @@
|
|||||||
# SSH
|
# SSH
|
||||||
generate_ssh_key: "{{ generate_ssh_key }}"
|
generate_ssh_key: "{{ generate_ssh_key }}"
|
||||||
ssh_key_type: "{{ ssh_key_type }}"
|
ssh_key_type: "{{ ssh_key_type }}"
|
||||||
|
ssh_key_comment: "{{ username }}@{{ ansible_fqdn }}"
|
||||||
# Groups
|
# Groups
|
||||||
groups: "{{ user_groups }}"
|
groups: "{{ user_groups }}"
|
||||||
append: "{{ groups_append }}"
|
append: "{{ groups_append }}"
|
||||||
@@ -57,3 +73,4 @@
|
|||||||
path: "/home/{{ username }}"
|
path: "/home/{{ username }}"
|
||||||
state: directory
|
state: directory
|
||||||
mode: "{{ homedir_permissions }}"
|
mode: "{{ homedir_permissions }}"
|
||||||
|
when: username != "root"
|
||||||
|
|||||||
Reference in New Issue
Block a user