get_gitlab_api_token.yml
Generate a gitlab token for pipeline checks in the playbook
- name: GitLab Post | Obtain Access Token
ansible.builtin.uri:
url: "{{ gitlab_protocol }}{{ gitlab_url }}oauth/token"
method: POST
validate_certs: false
body_format: json
headers:
Content-Type: application/json
body: >
{
"grant_type": "password",
"username": "{{ gitlab_user_username }}",
"password": "{{ gitlab_user_password }}"
}
register: gitlab_access_token
no_log: true
- name: Store the token in var
ansible.builtin.set_fact:
token: "{{ gitlab_access_token.json.access_token }}"
no_log: true