I am trying to write an ansible script to download files ( shell scripts ) from local bitbucket server.
Currently the code is as below. It asks for id and pw input and when I printed it, it prints a correct output.
But the get_url call returns an html page. The Id / pw entered does have access to the BB repo in question.
Is below not the correct way to pass credentials to bitbucket repo?
---
- name: Deployment of infrastructure changes
hosts: kafka_broker[0]
vars:
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no"
ansible_host_key_checking: false
date: "{{ lookup('pipe', 'date +%Y%m%d-%H%M%S') }}"
vars_prompt:
- name: bb_username
prompt: "User name for Bitbucket"
private: no
- name: bb_password
prompt: "Password for "
private: yes
tasks:
- name: Download connector scripts
get_url:
url: "http://bbserver:7990/projects/myproject/repos/myrepo/browse/scripts/{{ item }}"
dest: /var/scripts
url_username: '{{ bb_username }}'
url_password: '{{ bb_password }}'
with_items:
- script1.sh
- script2.sh
- script3.sh
register: showdlstatus
become: yes
become_user: '{{ bb_username }}'
How should I modify the above script to download files from BitBucket>
Thank you
Adding force_basic_auth: yes to the script resolved the issue
tasks:
- name: Download connector scripts
get_url:
url: "http://bbserver:7990/projects/myproject/repos/myrepo/raw/scripts/{{ item }}"
dest: /var/scripts
url_username: '{{ bb_username }}'
url_password: '{{ bb_password }}'
**force_basic_auth: yes**
with_items:
- script1.sh
- script2.sh
- script3.sh