---
- name: Copy SSH keys
  copy:
    content: "{{ ssh_key_item.value }}"
    dest: "{{ ansible_user_dir }}/.ssh/{{ ssh_key_item.key }}"
    mode: 0400
  loop_control:
    loop_var: ssh_key_item
  no_log: true
  with_items: "{{ ssh_key | default({}) | dict2items }}"

- name: Create SSH configuration file
  ansible.builtin.copy:
    content: "{{ ssh_config }}"
    dest: "{{ ansible_user_dir }}/.ssh/config"
    mode: 0400
  no_log: true
  when: ssh_config is defined