Make tests for group membership more readable

This commit is contained in:
Andreas B. Mundt 2024-11-21 11:20:26 +01:00
parent 8a25609749
commit 77f4643628
9 changed files with 24 additions and 24 deletions

View file

@ -100,9 +100,9 @@
- kerberize - kerberize
- lmn_security - lmn_security
- role: lmn_localhome - role: lmn_localhome
when: groups.localhome is defined and inventory_hostname in groups.localhome when: "'localhome' in group_names"
- role: lmn_teacherlaptop - role: lmn_teacherlaptop
when: groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop when: "'teacherlaptop' in group_names"
tasks: tasks:
## Temporary fixes and quirks: ## Temporary fixes and quirks:
@ -157,7 +157,7 @@
cmd: unzip -d /tmp/cb/ CodeBlocks.zip && dpkg -i cb/*.deb cmd: unzip -d /tmp/cb/ CodeBlocks.zip && dpkg -i cb/*.deb
chdir: /tmp/ chdir: /tmp/
when: new_codeblocks.changed | default(false) when: new_codeblocks.changed | default(false)
when: groups.PCroom is defined and inventory_hostname in groups.PCroom when: "'PCroom' in group_names"
## Clean up stuff from obsolete/faulty tasks: ## Clean up stuff from obsolete/faulty tasks:
- name: Remove sddm login screen patch with deprecated marker (homeondisk) - name: Remove sddm login screen patch with deprecated marker (homeondisk)
@ -301,7 +301,7 @@
blockinfile: blockinfile:
path: /etc/NetworkManager/NetworkManager.conf path: /etc/NetworkManager/NetworkManager.conf
state: absent state: absent
when: groups.laptop is defined and inventory_hostname not in groups.laptop when: "'laptop' not in group_names"
## bookworm fixes/hacks: ## bookworm fixes/hacks:
- name: Work around sddm hang on shutdown - name: Work around sddm hang on shutdown
@ -343,7 +343,7 @@
- role: lmn_wlan_iwd - role: lmn_wlan_iwd
when: ansible_interfaces | select('search', 'wl.+') | first is defined when: ansible_interfaces | select('search', 'wl.+') | first is defined
- role: lmn_localuser - role: lmn_localuser
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
tasks: tasks:
- name: Remove deprecated files and directories (laptop-class) - name: Remove deprecated files and directories (laptop-class)
file: file:

View file

@ -92,7 +92,7 @@
- plasma-discover - plasma-discover
autoremove: true autoremove: true
state: absent state: absent
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
- name: Make sure wireshark works for all users after installation and upgrades - name: Make sure wireshark works for all users after installation and upgrades
ansible.builtin.copy: ansible.builtin.copy:
@ -160,7 +160,7 @@
- pwroff.timer - pwroff.timer
- reporter.service - reporter.service
- reporter.timer - reporter.timer
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
- name: Enable pwroff.timer - name: Enable pwroff.timer
systemd: systemd:
@ -169,13 +169,13 @@
loop: loop:
- pwroff.timer - pwroff.timer
- reporter.timer - reporter.timer
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
- name: PXE first boot order - name: PXE first boot order
command: /usr/local/sbin/bootorder.sh command: /usr/local/sbin/bootorder.sh
register: cmd_result register: cmd_result
changed_when: cmd_result.stdout is not search('Nothing to do.') changed_when: cmd_result.stdout is not search('Nothing to do.')
when: groups.PCroom is defined and inventory_hostname in groups.PCroom when: "'PCroom' in group_names"
- name: Copy dolphin config scripts - name: Copy dolphin config scripts
ansible.builtin.copy: ansible.builtin.copy:
@ -220,7 +220,7 @@
[AC][SuspendSession] [AC][SuspendSession]
idleTime=7200000 idleTime=7200000
suspendType=8 suspendType=8
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
- name: Start with empty session by default - name: Start with empty session by default
ansible.builtin.copy: ansible.builtin.copy:
@ -251,7 +251,7 @@
Exec=lmn-fix-screen Exec=lmn-fix-screen
Type=Application Type=Application
NoDisplay=true NoDisplay=true
when: groups.CloneScreen is defined and inventory_hostname in groups.CloneScreen when: "'CloneScreen' in group_names"
#- name: Avoid starting kscreen (confusing autodetection) #- name: Avoid starting kscreen (confusing autodetection)
# ansible.builtin.copy: # ansible.builtin.copy:

View file

@ -117,7 +117,7 @@
path: /etc/systemd/sleep.conf.d/ path: /etc/systemd/sleep.conf.d/
state: directory state: directory
mode: '0755' mode: '0755'
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
- name: Avoid suspending - name: Avoid suspending
ansible.builtin.blockinfile: ansible.builtin.blockinfile:
@ -129,7 +129,7 @@
AllowHibernation=no AllowHibernation=no
AllowSuspendThenHibernate=no AllowSuspendThenHibernate=no
AllowHybridSleep=no AllowHybridSleep=no
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
- name: Deploy dolphin script - name: Deploy dolphin script
ansible.builtin.copy: ansible.builtin.copy:

View file

@ -7,7 +7,7 @@
https_proxy="{{ proxy }}" https_proxy="{{ proxy }}"
ftp_proxy="{{ proxy }}" ftp_proxy="{{ proxy }}"
no_proxy="{{ no_proxy }}" no_proxy="{{ no_proxy }}"
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
- name: Set aptcache - name: Set aptcache
ansible.builtin.copy: ansible.builtin.copy:
@ -27,4 +27,4 @@
deb http://deb.debian.org/debian/ {{ ansible_distribution_release }}-proposed-updates deb http://deb.debian.org/debian/ {{ ansible_distribution_release }}-proposed-updates
main non-free-firmware main non-free-firmware
state: present state: present
when: groups.R202 is defined and inventory_hostname in groups.R202 when: "'R202' in group_names"

View file

@ -12,7 +12,7 @@
ipv4.route-metric=2048 ipv4.route-metric=2048
[keyfile] [keyfile]
unmanaged-devices=interface-name:en*;interface-name:vm* unmanaged-devices=interface-name:en*;interface-name:vm*
when: groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop when: "'teacherlaptop' in group_names"
- name: Use iwd for USB-Wlan-Sticks but ignore interfaces managed by systemd-networkd (wlan0,en*) - name: Use iwd for USB-Wlan-Sticks but ignore interfaces managed by systemd-networkd (wlan0,en*)
blockinfile: blockinfile:
@ -26,7 +26,7 @@
ipv4.route-metric=2048 ipv4.route-metric=2048
[keyfile] [keyfile]
unmanaged-devices=interface-name:wlan0;interface-name:en*;interface-name:vm* unmanaged-devices=interface-name:wlan0;interface-name:en*;interface-name:vm*
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
- name: Enable Networkmanager - name: Enable Networkmanager
ansible.builtin.systemd: ansible.builtin.systemd:
@ -59,7 +59,7 @@
Name=enx{{ ansible_facts[ansible_interfaces | select('search', '^enp.*') | first].macaddress | replace(':','') }} Name=enx{{ ansible_facts[ansible_interfaces | select('search', '^enp.*') | first].macaddress | replace(':','') }}
[Network] [Network]
Bridge=virbr1 Bridge=virbr1
when: groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop when: "'teacherlaptop' in group_names"
- name: Configure systemd-networkd ethernet.network - name: Configure systemd-networkd ethernet.network
ansible.builtin.copy: ansible.builtin.copy:
@ -113,7 +113,7 @@
DHCP=yes DHCP=yes
[DHCPv4] [DHCPv4]
UseDomains=true UseDomains=true
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
- name: Enable systemd-networkd - name: Enable systemd-networkd
ansible.builtin.systemd: ansible.builtin.systemd:

View file

@ -38,7 +38,7 @@
line: 'SystemGroup root lpadmin role-teacher' line: 'SystemGroup root lpadmin role-teacher'
regexp: '^SystemGroup' regexp: '^SystemGroup'
state: present state: present
when: groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop when: "'teacherlaptop' in group_names"
- name: Disable cups-browsed - name: Disable cups-browsed
ansible.builtin.systemd: ansible.builtin.systemd:

View file

@ -17,6 +17,6 @@ ad_gpo_access_control = disabled
ad_gpo_ignore_unreadable = True ad_gpo_ignore_unreadable = True
ad_maximum_machine_account_password_age = 0 ad_maximum_machine_account_password_age = 0
ignore_group_members = True ignore_group_members = True
{% if groups.localhome is defined and inventory_hostname in groups.localhome %} {% if 'localhome' in group_names %}
override_homedir = /home/%u override_homedir = /home/%u
{% endif %} {% endif %}

View file

@ -60,7 +60,7 @@
><not><or><user>root</user><user>ansible</user><user>Debian-gdm</user><user>sddm</user><user>{{ localuser }}</user></or></not> ><not><or><user>root</user><user>ansible</user><user>Debian-gdm</user><user>sddm</user><user>{{ localuser }}</user></or></not>
</volume> </volume>
insertafter: "<!-- END ANSIBLE MANAGED BLOCK .* -->" insertafter: "<!-- END ANSIBLE MANAGED BLOCK .* -->"
when: groups.localhome is defined and inventory_hostname in groups.localhome when: "'localhome' in group_names"
- name: Use umount script for proper cleanup - name: Use umount script for proper cleanup
blockinfile: blockinfile:

View file

@ -57,11 +57,11 @@
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"
- name: Enable the enable-wifi service - name: Enable the enable-wifi service
ansible.builtin.systemd: ansible.builtin.systemd:
name: enable-wifi.service name: enable-wifi.service
enabled: True enabled: True
daemon_reload: True daemon_reload: True
when: not (groups.teacherlaptop is defined and inventory_hostname in groups.teacherlaptop) when: "'teacherlaptop' not in group_names"