# Get\_url won't get the raw file, but html

**URL:** <https://forum.ansible.com/t/get-url-wont-get-the-raw-file-but-html/42698>\
**Category:** Get Help\
**Created:** [May 16, 2025, 4:36am UTC](https://forum.ansible.com/t/get-url-wont-get-the-raw-file-but-html/42698 "2025-05-16T04:36:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [May 16, 2025, 4:36am UTC](https://forum.ansible.com/t/get-url-wont-get-the-raw-file-but-html/42698/1 "2025-05-16T04:36:44Z")

</div>

I have a bitbucket raw file

`https://devtools/bitbucket/projects/INA/repos/config/raw/etcd/dotfiles/.bashrc`

```auto
# .bashrc

# Source global definitions
if [-f /etc/bashrc]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# Bash prompt
export PS1='\u@\h:\w> '

# User specific aliases and functions
test -s ~/.alias && . ~/.alias || true
 
# import postgres environment
test -s /opt/custom/etcd/bin/.etcd.env && . /opt/custom/etcd/bin/.etcd.env || true
 
# set encoding and charset
LANG=de_DE.UTF-8
LC_MESSAGES=en_US.UTF-8
export LANG LC_MESSAGES
 
# define charset for less
export LESSCHARSET=utf-8

```

and a TASK like

```auto
  - name: get dotfiles from bitbucket
    delegate_to: localhost
    ansible.builtin.get_url:
      url: "{{ dotfiles_pull.src }}"
      dest: "{{ dotfiles_pull.dest }}"
    loop:
      - { 'src': "https://devtools/bitbucket/projects/INA/repos/config/raw/etcd/dotfiles/.bashrc", 'dest': ../temp/etcd_bashrc }
    loop_control:
      loop_var: "dotfiles_pull"

```

resulting into a downloaded file like

```auto
 <!DOCTYPE html><html lang="en" data-theme="dark:dark light:light" data-color-mode="light" ><head><meta charset="utf-8"><meta http-equiv= "X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width"><title>Log in - Bitbucket</title><script>
  1 window.WRM=window.WRM||{};window.WRM._unparsedData=window.WRM._unparsedData||{};window.WRM._unparsedErrors=window.WRM._unparsedErrors||{} ;
  2 WRM._unparsedData["com.atlassian.bitbucket.server.bitbucket-webpack-INTERNAL:user-keyboard-shortcuts-enabled.data"]="true";
  3 WRM._unparsedData["com.atlassian.analytics.analytics-client:programmatic-analytics-init.programmatic-analytics-data-provider"]="false";
  4 WRM._unparsedData["com.atlassian.plugins.atlassian-plugins-webresource-plugin:context-path.context-path"]="\u0022/bitbucket\u0022";
  5 WRM._unparsedData["com.atlassian.plugins.atlassian-clientside-extensions-runtime:runtime.atlassianDevMode"]="false";
...

```

so, I am getting the html of the site rather then to content of the raw file. Any idea what I am doing wrong?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://forum.ansible.com/u/ben.boeckel)\
**Post date:** [May 16, 2025, 5:39am UTC](https://forum.ansible.com/t/get-url-wont-get-the-raw-file-but-html/42698/2 "2025-05-16T05:39:16Z")

</div>

It looks like it is asking for authentication? Does `curl` on the URL return the file or a login page?

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [May 16, 2025, 8:28pm UTC](https://forum.ansible.com/t/get-url-wont-get-the-raw-file-but-html/42698/3 "2025-05-16T20:28:04Z")

</div>

thx, that hint was spot on.

this is how I could make it work

```auto
  delegate_to: localhost
  ansible.builtin.get_url:
    url: "{{ dotfiles_pull.src }}"
    dest: "{{ dotfiles_pull.dest }}"
    url_username: "{{ bb_user }}"
    url_password: "{{ bb_password }}"
    force_basic_auth: true
  loop:
    - { 'src': "{{ bb_etcd_config_repo }}dotfiles/.bashrc", 'dest': "{{ postgres_download_dir }}/etcd_bashrc" } ### wip
  loop_control:
    loop_var: "dotfiles_pull"

```

the relevant bits

```auto
    url_username: "{{ bb_user }}"
    url_password: "{{ bb_password }}"
    force_basic_auth: true

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 15, 2025, 8:29pm UTC](https://forum.ansible.com/t/get-url-wont-get-the-raw-file-but-html/42698/4 "2025-06-15T20:29:00Z")

</div>

Closed on June 15, 2025, 8:29pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
