ansible-infra/ansible_collections/debops/debops/roles/gitusers/tasks/gitusers.yml
Stefan Bethke 2aed20393f
Some checks failed
/ Ansible Lint (push) Failing after 5m45s
/ Ansible Lint (pull_request) Failing after 4m59s
Vendor Galaxy Roles and Collections
2026-02-06 22:07:16 +01:00

71 lines
3.4 KiB
YAML

---
# Copyright (C) 2014-2019 Maciej Delmanowski <drybjed@gmail.com>
# Copyright (C) 2015-2019 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only
- name: Manage user accounts without UIDs
ansible.builtin.user:
name: '{{ item.name + gitusers_name_suffix }}'
state: '{{ item.state | default("present") }}'
group: '{{ item.group | default(item.name + gitusers_name_suffix) }}'
comment: '{{ item.comment | default("") }}'
system: '{{ item.systemuser | default("no") }}'
shell: '{{ item.shell | default(gitusers_default_shell) }}'
home: '{{ item.home | default(gitusers_default_home_prefix + "/" + item.name + gitusers_name_suffix) }}'
createhome: 'no'
loop: '{{ q("flattened", gitusers_list
+ gitusers_group_list
+ gitusers_host_list) }}'
when: ((item.name is defined and item.name) and (item.uid is undefined or (item.uid is defined and not item.uid)))
- name: Manage user accounts with UIDs
ansible.builtin.user:
name: '{{ item.name + gitusers_name_suffix }}'
uid: '{{ item.uid }}'
state: '{{ item.state | default("present") }}'
group: '{{ item.group | default(item.name + gitusers_name_suffix) }}'
comment: '{{ item.comment | default("") }}'
system: '{{ item.systemuser | default("no") }}'
shell: '{{ item.shell | default(gitusers_default_shell) }}'
home: '{{ item.home | default(gitusers_default_home_prefix + "/" + item.name + gitusers_name_suffix) }}'
createhome: 'no'
loop: '{{ q("flattened", gitusers_list
+ gitusers_group_list
+ gitusers_host_list) }}'
when: ((item.name is defined and item.name) and (item.uid is defined and item.uid))
- name: Manage user default groups
ansible.builtin.user:
name: '{{ item.name + gitusers_name_suffix }}'
state: '{{ item.state | default("present") }}'
groups: '{{ gitusers_default_groups_list | join(",") }}'
append: '{{ gitusers_default_groups_append }}'
loop: '{{ q("flattened", gitusers_list
+ gitusers_group_list
+ gitusers_host_list) }}'
when: ((item.name is defined and item.name) and
(gitusers_default_groups_list is defined and gitusers_default_groups_list))
- name: Manage user custom groups
ansible.builtin.user:
name: '{{ item.name + gitusers_name_suffix }}'
state: '{{ item.state | default("present") }}'
groups: '{{ item.groups | join(",") }}'
append: '{{ item.append | default("yes") }}'
loop: '{{ q("flattened", gitusers_list
+ gitusers_group_list
+ gitusers_host_list) }}'
when: ((item.name is defined and item.name) and (item.groups is defined and item.groups))
- name: Enforce home directories permissions
ansible.builtin.file:
state: 'directory'
path: '{{ item.home | default(gitusers_default_home_prefix + "/" + item.name + gitusers_name_suffix) }}'
owner: '{{ item.name + gitusers_name_suffix }}'
group: '{{ item.group | default(item.name + gitusers_name_suffix) }}'
mode: '{{ gitusers_default_home_mode }}'
loop: '{{ q("flattened", gitusers_list
+ gitusers_group_list
+ gitusers_host_list) }}'
when: ((item.name is defined and item.name) and
(item.state is undefined or (item.state is defined and item.state != 'absent')))