Hello!
I want to use the content of a config file at GitHub to replace a config file at a host.
When i dowload the file its content rather looks like a siterip of the used link but not the actual content.
Please don’t post chat gpt answers if you insist on using it yourself. This is a bad solution because it’s unrelated to the issue.
If you’re using ansible-core out of the box (no custom legacy content), and not using the collections keyword in the playbook/none of collections contains a module called get_url, then get_url is the exact same as ansible.builtin.get_url.
Try downloading the raw file instead of the web page:
Thats even better THANK YOU AGAIN!
Is there something comparable when using GitLab?
We have an on-prem gitlab for our devs and my test-data will be migrated there.
And i see now that i got the raw. in my last code but not in the first so thats the reason in the beginning.
Even chatgpt stated it in the explanation…
Do you too have those moments when you start your day and see the mistake you got stuck the day before and think: why didnt i got it yesterday - it seems so obious.
A link to a GitLab file when opened in the browser looks like this: https://my.gitlab.com/team/group/project/-/blob/branch/file.txt?ref_type=heads
If you want the raw version of the file, it would look like this: https://my.gitlab.com/team/group/project/-/raw/branch/file.txt?ref_type=heads&inline=false
Im now at the Gitlab and have to use a litle diffrent playbook, because the GitLab Git isnt public.
Can i use the same credentials i used for the project?
and added the user i created for Gitlab in AD and its pw and still get a bad credetial error: remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password.
Hello!
I tried today to use your hint with the Url of the gitlab, but i got like in the beginning with github the content of the website, not the specific file:
The Playbook:
---
- name: Download specific file from GitLab with authentication
hosts: all
become: true
vars:
file_url: "https://git.gruen.net/awx_gruen/playbooks/-/raw/dev/linux_playbooks/fusion_inventory/agent.cfg"
tasks:
- name: Download the specific file with HTTP Basic Auth
ansible.builtin.uri:
url: "{{ file_url }}"
dest: "/tmp/agent.cfg"
method: GET
validate_certs: yes
url_username: "{{ GITLAB_USER }}"
url_password: "{{ GITLAB_TOKEN }}"
force_basic_auth: yes
when i add the ?ref_type=heads&inline=false nothing gets downloaded