Ansible-Linux_Base/roles/base/tasks/core_users.yml

34 lines
1,008 B
YAML
Raw Normal View History

2025-02-02 20:37:05 -07:00
---
# file: roles/base/tasks/core_users.yml
- name: "{{ user.username }} user setup"
user:
name: "{{ user.username }}"
password_lock: "{{ user.disable_password | default(false) }}"
- name: "Configure {{ user.username }} password"
user:
name: "{{ user.username }}"
password: "{{ user.password | default('*') }}"
when: user.password is defined
- name: "Setup {{ user.username }} authorized keys"
authorized_key:
user: "{{ user.username }}"
state: present
key: "{{ user.ssh_keys | join('\n') }}"
exclusive: "{{ user.ssh_keys_force | default('false') }}"
tags:
- authorized_key
when: ( user.ssh_keys is defined ) and ( user.ssh_keys is not url )
- name: "Setup {{ user.username }} authorized keys from url"
authorized_key:
user: "{{ user.username }}"
state: present
key: "{{ user.ssh_keys }}"
exclusive: "{{ user.ssh_keys_force | default('false') }}"
tags:
- authorized_key
when: ( user.ssh_keys is defined ) and ( user.ssh_keys is url )