---
- name: Ensure 0700 permission on ~/.ssh directory
  file:
    path: ~/.ssh
    mode: 0700
    state: directory

- name: Create config file if it doesn't exists
  file:
    path: ~/.ssh/config
    mode: 0600
    state: touch
  when: not dropbear_ssh_client

# Use blockinfile instead of lineinfile to have nice space
# between config section
- name: Configure OpenSSH to accept new host keys
  blockinfile:
    path: ~/.ssh/config
    block: |
      StrictHostKeyChecking accept-new
    insertbefore: BOF
    marker: '# {mark} CUSTOM SSH CONFIG'
    state: present
    mode: 0600
  when: not dropbear_ssh_client
