---
- name: Mount tmpfs on /home/{{ localuser }}
  ansible.posix.mount:
    name: /home/{{ localuser }}
    src: tmpfs
    fstype: tmpfs
    opts: uid=1001,gid=1001,mode=755,size=4G
    state: mounted

- name: Add local guest user
  ansible.builtin.user:
    name: "{{ localuser }}"
    comment: "Local Guest User,,,"
    shell: /bin/bash
    uid: 1001
    password_expire_min: 99999
    createhome: false
    password: "{{ localuser_pwd }}"

- name: Prepare generator for local guest user
  ansible.builtin.copy:
    dest: /etc/systemd/user-environment-generators/60-guest-user.sh
    content: |
      #!/usr/bin/bash
      set -eu
      [[ "$UID" -ne 1001 ]] && exit 0
      cp -r -n /etc/skel/.* "$HOME"
    mode: "0755"
