- hosts: morefine
  name: Install morefine
  become: yes
  tasks:
    - name: Install packages
      become: true
      ansible.builtin.apt:
        name: 
          - curl
          - yakuake
          - software-properties-common
          - apt-transport-https
          - wget
          - gpg
          - autokey-gtk
          - git
          - barrier
          - krusader
          - wine
          - kate
          - autofs
          - ethtool
          - python3-pip
          - telegram-desktop
    - name: Download gpg key for code
      get_url:
        url: https://packages.microsoft.com/keys/microsoft.asc
        dest: /tmp/tempkey
    - name: Import key for code
      become: true
      ansible.builtin.shell: >-
        gpg --dearmor < /tmp/tempkey > packages.microsoft.gpg

    - name: Install key for code
      become: true
      ansible.builtin.shell: >-
        install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
      
    - name: Add repo for code
      become: true
      ansible.builtin.shell: >-
        echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list
      
    - name: Install code
      become: true
      ansible.builtin.apt:
        name: 
          - code
    - name: Install viber
      become: true
      ansible.builtin.apt:
        deb: https://download.cdn.viber.com/cdn/desktop/Linux/viber.deb
    - name: Install VNC Viewer
      become: true
      ansible.builtin.apt:
        deb: https://downloads.realvnc.com/download/file/viewer.files/VNC-Viewer-7.5.1-Linux-x64.deb

    - name: Install VNC Server
      become: true
      ansible.builtin.apt:
        deb: http://192.168.77.106:48000/install/VNC-Server-6.11.0-Linux-x64.deb
      ignore_errors: true

    - name: Download gpg key for spotify
      get_url:
        url: https://download.spotify.com/debian/pubkey_7A3A762FAFD4A51F.gpg
        dest: /tmp/tempkey

    
    - name: Install key for spotify
      become: true
      ansible.builtin.shell: >-
        cat /tmp/tempkey |gpg --dearmor --yes -o /etc/apt/trusted.gpg.d/spotify.gpg


    - name: Add repo for spotify
      become: true
      ansible.builtin.shell: >-
        echo "deb http://repository.spotify.com stable non-free" | sudo tee /etc/apt/sources.list.d/spotify.list
    - name: Install spotify
      become: true
      ansible.builtin.apt:
        name: spotify-client
        update_cache: yes
    - name: Get repo
      become: true
      ansible.builtin.shell: >-
        add-apt-repository ppa:danielrichter2007/grub-customizer -y
    - name: Install grub-customizer
      become: true
      ansible.builtin.apt:
        name: grub-customizer
        update_cache: yes
    - name: Download gpg key for element
      become: true
      get_url:
        url: https://packages.element.io/debian/element-io-archive-keyring.gpg
        dest: /usr/share/keyrings/element-io-archive-keyring.gpg

    - name: Get repo element-desktop
      become: true
      ansible.builtin.shell: >-
        echo "deb [signed-by=/usr/share/keyrings/element-io-archive-keyring.gpg] https://packages.element.io/debian/ default main" | sudo tee /etc/apt/sources.list.d/element-io.list
    - name: Install element-desktop
      become: true
      ansible.builtin.apt:
        name: element-desktop
        update_cache: yes
    - name: Creating a file with content wol  service
      ansible.builtin.copy:
        dest: "/etc/systemd/system/wol@.service"
        content: |
          [Unit]
          Description=Wake-on-LAN for %i
          Requires=network.target
          After=network.target

          [Service]
          ExecStart=/usr/sbin/ethtool -s %i wol g
          Type=oneshot

          [Install]
          WantedBy=multi-user.target
    - name: Just force systemd to reread configs (2.4 and above)
      ansible.builtin.systemd:
        daemon_reload: true
    - name: Enable wol@eno1
      ansible.builtin.systemd:
        name: wol@eno1
        state: started
        enabled: true
