This repository has been archived on 2024-05-02. You can view files and clone it, but cannot push or open issues or pull requests.
omni-ansible/tasks/preprocess-users.yml

40 lines
1.1 KiB
YAML
Raw Normal View History

---
- name: Load users variables
include_vars:
file: users.yml
- name: Reconcile user targets with host targets to get host users
set_fact:
_users_local: >-
{{
_users_local | default([]) + ([item] if item.targets | intersect(omni_local_targets) else [])
}}
loop: "{{ omni_users }}"
- name: Determine local user names
set_fact:
_users_local_names: "{{ _users_local_names | default([]) + [item.name] }}"
loop: "{{ _users_local }}"
- name: Determine administrative users
set_fact:
_users_local_admin: >-
{{
_users_local_admin | default([]) + ([item] if item.admin | default(False) else [])
}}
loop: "{{ _users_local }}"
- name: Determine existing users
shell: 'grep omni /etc/group | cut -d: -f4 | tr "," "\n"'
changed_when: false
register: _users_local_existing
- name: Determine removed users
set_fact:
_users_local_removed: >-
{{
_users_local_removed | default([]) +
([item] if item not in _users_local_names else [])
}}
loop: "{{ _users_local_existing.stdout_lines }}"