Not able to checkout my git repo from ansible using ssh.

Bela Vaishali Chuphal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 27, 2018

The following is my tasks list-

---

- name: create user
user: name={{server_user}} state=present

#TO Do: perform below task using forwarding Agent
- name: Create the Bitbucket SSH public key file
copy:
src: "~/.ssh/id_rsa.pub"
dest: "{{ home_dir }}/.ssh/id_rsa_bitbucket.pub"
mode: 0644
owner: "{{ server_user }}"
group: "{{ server_user }}"
tags:
- deploy

- name: Create the Bitbucket SSH private key file
copy:
src: "~/.ssh/id_rsa"
dest: "{{ home_dir}}/.ssh/id_rsa_bitbucket"
mode: 0660
owner: "{{ server_user }}"
group: "{{ server_user }}"
tags:
- deploy

- name: setup the git repo
git:
repo: "{{git_repo}}"
version: "{{git_branch}}"
dest: "{{repo_path}}"
accept_hostkey: yes
force: yes
key_file: "{{ home_dir}}/.ssh/id_rsa_bitbucket"
tags:
- deploy


Main.yml



# General
server_user: www-data
repo_path: /opt/apps/surbo_third_party_integrations
workspace_path: /opt/apps/
home_dir: "/home/{{ansible_user}}"
server_log: /var/log
app_log_path: /var/log/surbo_clients/app.log
debug_log_path: /var/log/surbo_clients/debug.log

# Git settings
git_repo: git@bitbucket.org:infinito-admin/surbo_third_party_integrations.git
git_branch: master

# Virtualenv settings │
virtualenv_path: /opt/.venv_surbo_clients

 

And the command used is

ansible-playbook -v surbo_clients.yml -i environments/uat/inventory -t deploy

However when setup the git repo task is launched it ends in an infinite loop

1 answer

0 votes
Daniel Santos
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 4, 2019

Hi @Bela Vaishali Chuphal,

We wold need more debugging details to determine what can be causing this scenario.

  • Is this behavior only observed in Ansible?
  • Are you able to checkout and update the repository details from normal git client in your machine?

If this problem is only happening in Ansible, I'm afraid you should try looking for help at https://www.ansible.com/community.

In case the problem happens also outside Ansible we will need to add some extra debugging to understand what is happening.you could try this prior to run your git command:

export GIT_TRACE_PACKET=1
export GIT_TRACE=1 
export GIT_CURL_VERBOSE=1

 

Ah, It just occurred to me that if Ansible is able to use the bitbucket repo with user and password, it could be some issue when approving the finger print of Bitbucket.org for example.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events