- name: Check if ssh keys exists stat: path: "{{ ansible_user_dir }}/.ssh/id_rsa" register: ssh_key - name: Use SSH repositories set_fact: git: "{{ git_repos.ssh }}" when: ssh_key.stat.exists - name: Use HTTPS repositories set_fact: git: "{{ git_repos.https }}" when: not ssh_key.stat.exists