Do not try to run useradd/groupadd if mash_playbook_uid/mash_playbook_gid explicitly specified
Certain environments (like https://libreelec.tv/) do not have `useradd`/`groupadd` tools, so it's important to be able to avoid calling them, especially for no good reason.
This commit is contained in:
parent
2a8aebf309
commit
cd7ef92fb4
1 changed files with 22 additions and 20 deletions
|
@ -1,24 +1,26 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- name: Ensure mash group is created
|
- when: not mash_playbook_uid and not mash_playbook_uid
|
||||||
ansible.builtin.group:
|
block:
|
||||||
name: "{{ mash_playbook_user_groupname }}"
|
- name: Ensure mash group is created
|
||||||
gid: "{{ omit if mash_playbook_gid is none else mash_playbook_gid }}"
|
ansible.builtin.group:
|
||||||
state: present
|
name: "{{ mash_playbook_user_groupname }}"
|
||||||
register: mash_base_group_result
|
gid: "{{ omit if mash_playbook_gid is none else mash_playbook_gid }}"
|
||||||
|
state: present
|
||||||
|
register: mash_base_group_result
|
||||||
|
|
||||||
- name: Ensure mash user is created
|
- name: Ensure mash user is created
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ mash_playbook_user_username }}"
|
name: "{{ mash_playbook_user_username }}"
|
||||||
uid: "{{ omit if mash_playbook_uid is none else mash_playbook_uid }}"
|
uid: "{{ omit if mash_playbook_uid is none else mash_playbook_uid }}"
|
||||||
state: present
|
state: present
|
||||||
group: "{{ mash_playbook_user_groupname }}"
|
group: "{{ mash_playbook_user_groupname }}"
|
||||||
home: "{{ mash_playbook_base_path }}"
|
home: "{{ mash_playbook_base_path }}"
|
||||||
create_home: false
|
create_home: false
|
||||||
system: true
|
system: true
|
||||||
register: mash_base_user_result
|
register: mash_base_user_result
|
||||||
|
|
||||||
- name: Initialize mash_playbook_uid and mash_playbook_gid
|
- name: Initialize mash_playbook_uid and mash_playbook_gid
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
mash_playbook_uid: "{{ mash_base_user_result.uid }}"
|
mash_playbook_uid: "{{ mash_base_user_result.uid }}"
|
||||||
mash_playbook_gid: "{{ mash_base_group_result.gid }}"
|
mash_playbook_gid: "{{ mash_base_group_result.gid }}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue