fix mgrote_users "wantlist" #203

Merged
mg merged 10 commits from us into master 2024-10-08 17:02:29 +02:00
Showing only changes of commit a63741d4ed - Show all commits

View file

@ -1,15 +1,11 @@
--- ---
- name: set groups as list - name: Set groups as list
ansible.builtin.set_fact: ansible.builtin.set_fact:
groups_as_list: "{{ ((( item.groups ) | list) | sort) | unique }}" groups_as_list: "{{ ((( item.groups ) | list) | sort) | unique }}"
loop: "{{ users }}" loop: "{{ users }}"
when: item.groups is defined when: item.groups is defined
- name: debug 1 - name: Ensure groups exist
ansible.builtin.debug:
msg: '{{ groups_as_list }}'
- name: create groups
ansible.builtin.group: ansible.builtin.group:
name: "{{ item }}" name: "{{ item }}"
state: present state: present
@ -17,7 +13,7 @@
when: groups_as_list is defined when: groups_as_list is defined
# no_log: true # TODO # no_log: true # TODO
- name: create users - name: Ensure users exist
ansible.builtin.user: ansible.builtin.user:
name: "{{ item.username }}" name: "{{ item.username }}"
uid: "{{ item.uid | default(omit) }}" uid: "{{ item.uid | default(omit) }}"
@ -30,15 +26,16 @@
loop: '{{ users }}' loop: '{{ users }}'
# no_log: true # TODO # no_log: true # TODO
- name: add ssh key - name: Ensure user ssh-keys exist
ansible.posix.authorized_key: ansible.posix.authorized_key:
user: "{{ item.username }}" user: "{{ item.username }}"
key: "{{ item.public_ssh_key }}" key: "{{ item.public_ssh_key }}"
state: present state: present
when: item.public_ssh_key is defined when: item.public_ssh_key is defined
loop: '{{ users }}' loop: '{{ users }}'
# no_log: true # TODO
- name: add to sudoers - name: Ensure users are added to sudoers
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
dest: /etc/sudoers dest: /etc/sudoers
state: present state: present
@ -47,3 +44,4 @@
validate: 'visudo -cf %s' validate: 'visudo -cf %s'
when: item.allow_sudo|default(false) and item.allow_sudo is defined when: item.allow_sudo|default(false) and item.allow_sudo is defined
loop: '{{ users }}' loop: '{{ users }}'
# no_log: true # TODO