Need to download Multiple files from Gitlab using Ansible

1,032 views
Skip to first unread message

Amit Kulkarni

unread,
May 24, 2023, 9:08:05 PM5/24/23
to Ansible Project
Hello All,

I need to download multiple files from Gitlab, i am able to download one file using below playbook but I need help to download multiple files from Gitlab. Here is the sample playbook I wanted to read the file names into ansible playbook and download from Gitlab.

Appreciate  your help on this
 

---
- hosts: dbserver
  gather_facts: no
  tasks:
   - name: Download File from Gitlab
     become: yes
     get_url:
      url: https://github.com/kamitv/devops/blob/master/FileA.txt
      url_username: kamitv
      url_password: XXXXXXX
      dest: /home/ubuntu/


Regards
Amit


Dick Visser

unread,
May 25, 2023, 2:00:40 AM5/25/23
to ansible...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAON3ZR3aUTBpj%3Dba_NWwc%2BAMdSzujFiLCFJZ%2BV%2BiYi731E%3DvUQ%40mail.gmail.com.
--
Sent from Gmail Mobile

Amit Kulkarni

unread,
May 25, 2023, 9:26:10 AM5/25/23
to ansible...@googlegroups.com
Hello Dick,

Thanks for the response, I am able to download the files however its downloading everything (showing all html codes, design code for github webpage etc).

Is there any way to get the contents of the actual file and not the entire page contents.

---
- hosts: dbserver
  vars_prompt:
    - name: "gitlabuser"
      prompt: "Enter your  Github Username"
      private: no
    - name: "gitlabpassword"
      prompt: "Enter your  Gitlab Password"
      private: yes
  tasks:
  - get_url:
      url: "{{ item }}"
      dest: /home/ubuntu
    register: download
    until: download is succeeded
    delay: 3
    loop:


Here is the output when I open these files, I just need the contents of these files to be in these text file, anyway we can get this ?
<!DOCTYPE html>
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system">
  <head>
    <meta charset="utf-8">
  <link rel="dns-prefetch" href="https://github.githubassets.com">
  <link rel="dns-prefetch" href="https://avatars.githubusercontent.com">
  <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com">
  <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/">
  <link rel="preconnect" href="https://github.githubassets.com" crossorigin>
  <link rel="preconnect" href="https://avatars.githubusercontent.com">



  <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/light-0946cdc16f15.css" /><link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/dark-3946c959759a.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-9b9a8c91acc5.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-11302a585e33.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-1a4564ab0fbf.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-12a8b2aa9101.css" /><link data-color-theme="light_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_high_contrast-5924a648f3e7.css" /><link data-color-theme="light_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_tritanopia-05358496cb79.css" /><link data-color-theme="dark_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_tritanopia-aad6b801a158.css" />

Dick Visser

unread,
May 25, 2023, 11:08:33 AM5/25/23
to ansible...@googlegroups.com
On Thu, 25 May 2023 at 15:26, Amit Kulkarni <amit1...@gmail.com> wrote:
>
> Hello Dick,
>
> Thanks for the response, I am able to download the files however its downloading everything (showing all html codes, design code for github webpage etc).
>
> Is there any way to get the contents of the actual file and not the entire page contents.

You are getting what you asked for, because these URLs are the web
pages that describe the file.
If you want the actual files, then you'd need to use the Github raw file URL.
The web page has a special button for that.
In your case the URL would look like:

https://raw.githubusercontent.com/kamitv/devops/master/FileB.txt

etc
Reply all
Reply to author
Forward
0 new messages