- name: SSH keys deploy
  become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
  block:
    - name: Create dir
      ansible.builtin.file:
        path: /home/jd/.ssh
        owner: jd
        group: jd
        mode: '0700'
        state: directory
    - name: Upload key
      ansible.builtin.copy:
        src: id_rsa
        dest: /home/jd/.ssh/id_rsa
        mode: '0600'
        owner: jd
        group: jd
      when: inventory_hostname != 'nas.home.lan'
    - name: Upload key
      ansible.builtin.copy:
        src: id_rsa.pub
        dest: /home/jd/.ssh/id_rsa.pub
        mode: '0600'
        owner: jd
        group: jd
      when: inventory_hostname != 'nas.home.lan'
    - name: Set authorized key taken from file
      ansible.posix.authorized_key:
        user: jd
        state: present
        key: "{{ lookup('file', '/home/jd/.ssh/id_rsa.pub') }}"
