---
- name: Set up ssh
  vars:
    uid: "{{ lookup('env','USER') }}"
  hosts: localhost
  connection: local
  become: false
  tasks:
    - name: Create ssh dir
      ansible.builtin.file:
        dest: /home/{{ uid }}/.ssh
        state: directory
    - name: Install authorized keys
      ansible.builtin.template:
        src: ../templates/authorized_keys.j2
        dest: /home/{{ uid }}/.ssh/authorized_keys
        owner: '{{ uid }}'
        group: '{{ uid }}'
        mode: '0600'
    - name: Install pub key
      ansible.builtin.template:
        src: ../templates/id_rsa_yubikey.pub.j2
        dest: /home/{{ uid }}/.ssh/id_rsa_yubikey.pub
        owner: '{{ uid }}'
        group: '{{ uid }}'
        mode: '0600'
    - name: Install ssh config
      ansible.builtin.template:
        src: ../templates/ssh_config.j2
        dest: /home/{{ uid }}/.ssh/config
        owner: '{{ uid }}'
        group: '{{ uid }}'
        mode: '0600'
    
