ansible-role-strfry/tasks/setup-user.yml

40 lines
925 B
YAML

---
- name: Get nologin path for strfry user
ansible.builtin.find:
paths:
- /bin
- /sbin
- /usr/bin
- /usr/sbin
patterns: nologin
register: nologin_bin
become: true
- name: Create the strfry group
ansible.builtin.group:
name: "{{ strfry_system_group }}"
state: present
system: true
when: strfry_system_group != "root"
become: true
- name: Create the strfry system user
ansible.builtin.user:
name: "{{ strfry_system_user }}"
groups: "{{ strfry_system_group }}"
shell: "{{ nologin_bin.files[0].path }}"
system: true
create_home: false
home: "{{ strfry_data_path }}"
when: strfry_system_user != "root"
become: true
- name: Ensure strfry_path exists.
ansible.builtin.file:
path: "{{ strfry_data_path }}"
owner: "{{ strfry_system_user }}"
group: "{{ strfry_system_group }}"
state: directory
mode: '0750'
become: true