Skip to content

Commit

Permalink
fix: don't modify system user or group if they already exist
Browse files Browse the repository at this point in the history
Signed-off-by: gardar <[email protected]>
  • Loading branch information
gardar committed Oct 17, 2024
1 parent 90ab1fb commit e8da64e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions roles/_common/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@
tags:
- always

- name: "Gather system user and group facts"
ansible.builtin.getent:
database: "{{ item }}"
loop:
- passwd
- group
tags:
- "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}"
- install
- "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}_install"

- name: "Create system group {{ _common_system_group }}"
ansible.builtin.group:
name: "{{ _common_system_group }}"
system: true
state: present
become: true
when: _common_system_group != "root"
when: _common_system_group not in ansible_facts.getent_group
tags:
- "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}"
- install
Expand All @@ -29,7 +40,7 @@
home: "{{ _common_config_dir | default('/') }}"
create_home: false
become: true
when: _common_system_user != "root"
when: _common_system_user not in ansible_facts.getent_passwd
tags:
- "{{ ansible_parent_role_names | first | regex_replace(ansible_collection_name ~ '.', '') }}"
- install
Expand Down

0 comments on commit e8da64e

Please sign in to comment.