---
# Install and activate tigervnc
# NOTE: You will still need to log in manually as the new user and run "passwd" and "vncpasswd"
- name: Ensure tigervnc-server is installed
  dnf:
    name: 
    - tigervnc-server
  become: yes
- name: Copy systemd file to /etc/system/system
  copy:
    remote_src: yes
    src: /lib/systemd/system/vncserver@.service
    dest: /etc/systemd/system/vncserver@.service
  become: yes
- name: Copy vncserver.users
  copy:
    src: files/vncserver.users
    dest: /etc/tigervnc/vncserver.users
  become: yes
- name: Create vncuser
  user:
    name: vncuser
    shell: /bin/fish
    groups: wheel
    append: yes
  become: yes
- name: Ensure .vnc folder exists for vncuser
  file:
    path: /home/vncuser/.vnc
    state: directory
    owner: vncuser
    group: vncuser
  become: yes
- name: Copy vnc config
  copy:
    src: files/config
    dest: /home/vncuser/.vnc/config
    owner: vncuser
    group: vncuser
  become: yes
- name: Copy xstartup
  copy:
    src: files/xstartup
    dest: /home/vncuser/.vnc/xstartup
    owner: vncuser
    group: vncuser
  become: yes
- name: Start tigervnc service
  systemd:
    name: vncserver@:2
    state: started
    enabled: yes
  become: yes
- name: UFW Allow 5902/tcp
  community.general.ufw:
    rule: allow
    port: 5902
    proto: tcp
  become: yes
