When I try to clone a repository from Bitbucket with Ansible, it seems like the task 'hangs'.
In the documentation I have found some information, but I'm not using SSH.
If the task seems to be hanging, first verify remote host is in known_hosts. SSH will prompt user to authorize the first contact with a remote host. One solution is to add StrictHostKeyChecking no in .ssh/config which will accept and authorize the connection on behalf of the user. However, if you run as a different user such as setting sudo to True), for example, root will not look at the user .ssh/config setting.
These are the two Playbooks I've tried. They both 'hangs'.
Playbook #1
- hosts: staging_mysql
user: ec2-user
sudo: yes
vars_files:
- vars/mercurial.yml
tasks:
- name: Mercurial credentials setup
action: template src=templates/hgrc.j2 dest=/home/ec2-user/.hgrc
- name: Install Mercurial
action: yum name=hg
- name: Setup API repository
action: command hg clone https://[email protected]/username/my-repo -r default --debug
Playbook #2
- hosts: staging_mysql
user: ec2-user
sudo: yes
vars_files:
- vars/mercurial.yml
tasks:
- name: Mercurial credentials setup
action: template src=templates/hgrc.j2 dest=/home/ec2-user/.hgrc
- name: Install Mercurial
action: yum name=hg
- name: Clone API repo
hg: dest=/home/ec2-user repo=https://[email protected]/username/my-repo
Any help is welcome. Thanks in advance!