---
- hosts: debianhosts
  tasks:
  - name: change working directory
    ansible.builtin.shell:
      cmd: ls -l
      chdir: /tmp
  
  - name: Get beszel agent install script
    become: yes
    get_url:
      url: https://get.beszel.dev
      dest: /tmp/install-agent.sh

  - name: Change file ownership, group and permissions
    ansible.builtin.file:
      path: /tmp/install-agent.sh
      # owner: root
      # group: root
      mode: '0755'

  - name: Execute beszel agent install script
    ansible.builtin.shell:
      cmd: /tmp/install-agent.sh -p 45876 -k "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhA2xm3yiEqzi5dn8UerbbhZTkU538O1g1KF2d7LefT" #stopping here as this command requires input.
  
  - name: Add beszel agent key
    ansible.builtin.shell:
      cmd: echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhA2xm3yiEqzi5dn8UerbbhZTkU538O1g1KF2d7LefT" >> /root/.ssh/authorized_keys

- hosts: windowshosts
  tasks:
  - name: Install linux beszel agent
    command: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser; & iwr -useb https://get.beszel.dev -OutFile "$env:TEMP\install-agent.ps1"; & "$env:TEMP\install-agent.ps1" -Key "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEhA2xm3yiEqzi5dn8UerbbhZTkU538O1g1KF2d7LefT" -Port 45876