Ansible Git Module - Private Key Not Found

By Tyler on

Ansible’s git module fails when given a relative path for key_file. The realpath jinga2 filter solves this problem.

- name: Deploy using Git over SSH
  git: repo=ssh://git@example.com/foo.git
       dest=/bar
       version=master
       key_file={{ "ssh_keys/id_rsa" | realpath }}
       accept_hostkey=true
       force=yes