Adding user state management
This commit is contained in:
parent
5a88ccb426
commit
7c91db950b
2 changed files with 7 additions and 2 deletions
|
@ -17,6 +17,7 @@ base_users: []
|
|||
# ssh_keys_force: false # setting ssh_keys_force to true will overwrite the authorized_keys file to only be the ssh keys provided
|
||||
# groups: []
|
||||
# groups_append: true
|
||||
# state: present
|
||||
|
||||
# Install all available updates at runtime
|
||||
base_core_install_updates: true
|
||||
|
|
|
@ -4,11 +4,14 @@
|
|||
- name: "{{ user.username }} user setup"
|
||||
user:
|
||||
name: "{{ user.username }}"
|
||||
state: "{{ user.state | default('present') }}"
|
||||
force: true
|
||||
password_lock: "{{ user.disable_password | default(false) }}"
|
||||
|
||||
- name: "{{ user.username }} group setup"
|
||||
user:
|
||||
name: "{{ user.username }}"
|
||||
state: "{{ user.state | default('present') }}"
|
||||
groups: "{{ user.groups | join(',') }}"
|
||||
append: "{{ user.groups_append | default('true') }}"
|
||||
when: user.groups is defined
|
||||
|
@ -16,13 +19,14 @@
|
|||
- name: "Configure {{ user.username }} password"
|
||||
user:
|
||||
name: "{{ user.username }}"
|
||||
state: "{{ user.state | default('present') }}"
|
||||
password: "{{ user.password | default('*') }}"
|
||||
when: user.password is defined
|
||||
|
||||
- name: "Setup {{ user.username }} authorized keys"
|
||||
authorized_key:
|
||||
user: "{{ user.username }}"
|
||||
state: present
|
||||
state: "{{ user.state | default('present') }}"
|
||||
key: "{{ user.ssh_keys | join('\n') }}"
|
||||
exclusive: "{{ user.ssh_keys_force | default('false') }}"
|
||||
tags:
|
||||
|
@ -32,7 +36,7 @@
|
|||
- name: "Setup {{ user.username }} authorized keys from url"
|
||||
authorized_key:
|
||||
user: "{{ user.username }}"
|
||||
state: present
|
||||
state: "{{ user.state | default('present') }}"
|
||||
key: "{{ user.ssh_keys }}"
|
||||
exclusive: "{{ user.ssh_keys_force | default('false') }}"
|
||||
tags:
|
||||
|
|
Loading…
Add table
Reference in a new issue