---
- name: create ssh directory if not exists
  file:
    path: /root/.ssh
    state: directory

- name: move ssh key into place
  template:
    src: ansible_pub_user.pem.j2
    dest: /root/.ssh/ansible_pub_user.pem

- name: set key permissions
  file:
    path: /root/.ssh/ansible_pub_user.pem
    state: file
    owner: root
    group: root
    mode: 0400

- name: add ssh config for github
  blockinfile:
    path: /root/.ssh/config
    create: yes
    block:  |
      Host {{ git_host }}
          User git
          PreferredAuthentications publickey
          IdentityFile /root/.ssh/ansible_pub_user.pem
          StrictHostKeyChecking no
