# GitLab + AWX questions

**URL:** <https://forum.ansible.com/t/gitlab-awx-questions/4351>\
**Category:** Get Help\
**Tags:** gitlab, playbook, awx\
**Created:** [March 13, 2024, 9:34am UTC](https://forum.ansible.com/t/gitlab-awx-questions/4351 "2024-03-13T09:34:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gothsome](https://avatars.discourse-cdn.com/v4/letter/g/278dde/32.png) [@gothsome](https://forum.ansible.com/u/gothsome)\
**Post date:** [March 13, 2024, 9:34am UTC](https://forum.ansible.com/t/gitlab-awx-questions/4351/1 "2024-03-13T09:34:01Z")

</div>

Hello!  
I still have problems to get a file from GitLab to a host.

I try to dl the file but get the message access denied:  
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.  
Playbook:

```auto
---
- name: Download with PAT
  hosts: all
  become: true

  vars:
    gitlab_user: "{{ 'GITLAB_USER' }}"
    gitlab_token: "{{ 'GITLAB_TOKEN' }}"
    git_repo: "https://git.gruen.net/awx_gruen/playbooks.git"

  tasks:
    - name: clone from repo to tmp
      ansible.builtin.git:
        repo: "https://{{ gitlab_user }}:{{ gitlab_token }}@{{ git_repo | regex_replace('https://', '') }}"
        dest: "/tmp/"
        version: "dev"
        force: yes
        accept_hostkey: yes

```

i use the PAT as token var and can auth with this data co clone the git with:

```auto
git clone https://git.gruen.net/awx_gruen/playbooks.git /tmp/

```

I replaced the PAT value once to make shure.  
And how could i download just a singlie file:  
[https://git.gruen.net/awx\_gruen/playbooks/-/blob/dev/linux\_playbooks/fusion\_inventory/agent.cfg?ref\_type=heads](https://git.gruen.net/awx_gruen/playbooks/-/blob/dev/linux_playbooks/fusion_inventory/agent.cfg?ref_type=heads)

And i have read about the possibillity to use a webhoock to trigger a project sync if there has been an change in the files.

I have seen two versions:  
One from the official guide where you enable a webhoock in a Template and enter there the webhoock data - i think this i just for messaging if the template has been run or propably data from it to the GitLab(?) 🤨

The [other](https://itnext.io/implementing-ansible-awx-gitlab-integration-52c98f113ad0) one uses the service [Webhoock](https://github.com/adnanh/webhook) but i dont get how the AWX is actepting the request to sync the project in this version. 🤔

Thank you again for your input!!

---

<div class="post-metadata">

**Author:** ![gothsome](https://avatars.discourse-cdn.com/v4/letter/g/278dde/32.png) [@gothsome](https://forum.ansible.com/u/gothsome)\
**Post date:** [March 14, 2024, 10:44am UTC](https://forum.ansible.com/t/gitlab-awx-questions/4351/2 "2024-03-14T10:44:22Z")

</div>

I got now a functional playbook to clone the repo:

```auto
---
- name: Download with PAT
  hosts: all
  become: true

  tasks:
    - name: check for /tmp/git
      ansible.builtin.file:
        path: "/tmp/git"
        state: directory
        mode: '0755'

    - name: clone from repo to tmp
      ansible.builtin.git:
        repo: "https://{{ GITLAB_USER | urlencode() }}:{{ GITLAB_TOKEN | urlencode() }}@git.gruen.net/awx_gruen/playbooks.git"
        dest: "/tmp/git"
        version: "dev"
        force: yes
        accept_hostkey: yes

```

---

<div class="post-metadata">

**Author:** ![Incrediblestorm](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/incrediblestorm/32/3561_2.png) [@Incrediblestorm](https://forum.ansible.com/u/Incrediblestorm)\
**Post date:** [June 15, 2024, 12:40am UTC](https://forum.ansible.com/t/gitlab-awx-questions/4351/3 "2024-06-15T00:40:25Z")

</div>

You might look at setting header values. Our instance has the same response, and I believe the method to get around it is to create a project token and use the headers.  
I just got through an issue like this, with downloading an archive file of a repo, but it should be the same for your single file case.

PRIVATE-TOKEN: glpat-blahblahblah

Would be the header. You might have to download it via get\_url though.

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [June 15, 2024, 1:52am UTC](https://forum.ansible.com/t/gitlab-awx-questions/4351/4 "2024-06-15T01:52:31Z")

</div>

You could also look at using gitlab runners to vet the merge, either before, or after, or both (`ansible-lint` and such), and let the runner notify AWX to pull when it passes your criteria. We do a little of that, but we mostly use Jenkins — it was set up and working before we knew about gitlab runners, and it still works fine.
