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

36 lines
865 B
YAML

---
- name: Get nologin path for strfry user
ansible.builtin.find:
paths:
- /bin
- /sbin
- /usr/bin
- /usr/sbin
patterns: nologin
register: nologin_bin
- name: Create the strfry group
ansible.builtin.group:
name: "{{ strfry_system_group }}"
state: present
system: true
when: strfry_system_group != "root"
- 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"
- name: Ensure strfry_path exists.
ansible.builtin.file:
path: "{{ strfry_data_path }}"
owner: "{{ strfry_system_user }}"
group: "{{ strfry_system_group }}"
state: directory
mode: '0750'