Skip to content

Commit

Permalink
Merge pull request #428 from gardar/fix-usermod
Browse files Browse the repository at this point in the history
fix: don't modify system user or group if they already exist
  • Loading branch information
gardar authored Oct 17, 2024
2 parents 90ab1fb + e8da64e commit d4ed057
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 d4ed057

Please sign in to comment.