---
- name: Include access vars
  ansible.builtin.include_vars:
    file: vars/access.yaml

- name: Determine local user accounts
  when: skylab_targets | intersect(item.targets | default([]))
  vars:
    _local_users: []
  ansible.builtin.set_fact:
    _local_users: "{{ _local_users + [item] }}"
  loop: "{{ skylab_accounts }}"
  loop_control:
    label: "{{ item.name }},{{ item.uid }}"

- name: Determine local human user accounts
  when: not (item.service | default(false))
  vars:
    _local_human_users: []
  ansible.builtin.set_fact:
    _local_human_users: "{{ _local_human_users + [item.name] }}"
  loop: "{{ _local_users }}"
  loop_control:
    label: "{{ item.name }},{{ item.uid }}"

- name: Determine local admin user accounts
  when: item.admin | default(false)
  vars:
    _local_admin_users: []
  ansible.builtin.set_fact:
    _local_admin_users: "{{ _local_admin_users + [item.name] }}"
  loop: "{{ _local_users }}"
  loop_control:
    label: "{{ item.name }},{{ item.uid }}"

- name: Install software
  ansible.builtin.import_tasks: software.yml

- name: Configure environment
  ansible.builtin.import_tasks: environment.yml
