--- - name: "Defined ssh_private_key_path - Check to see if there is a file where the ssh_private_key_path is defined" stat: path: "{{ ssh_private_key_path }}" register: test_ssh_private_key_path delegate_to: localhost - name: "Defined ssh_private_key_path - Error if ssh_private_key_path is not valid" fail: msg: "ssh_private_key_path is not valid." when: not test_ssh_private_key_path.stat.exists delegate_to: localhost - name: "Defined ssh_private_key_path - Read SSH private key in" set_fact: ssh_private_key="{{ lookup('file', ssh_private_key_path ) }}" no_log: true