2022-08-05 21:56:40 +02:00
|
|
|
---
|
2021-12-09 21:02:58 +01:00
|
|
|
####################################################################
|
|
|
|
# WARNING: These are designed specifically for Ansible tests #
|
|
|
|
# and should not be used as examples of how to write Ansible roles #
|
|
|
|
####################################################################
|
|
|
|
|
2022-08-05 21:56:40 +02:00
|
|
|
# Copyright (c) Ansible Project
|
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-12-09 21:02:58 +01:00
|
|
|
- name: Install required libs
|
|
|
|
pip:
|
|
|
|
name: python-gitlab
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create {{ gitlab_project_name }}
|
|
|
|
gitlab_project:
|
|
|
|
server_url: "{{ gitlab_host }}"
|
|
|
|
validate_certs: False
|
|
|
|
login_token: "{{ gitlab_login_token }}"
|
|
|
|
name: "{{ gitlab_project_name }}"
|
|
|
|
initialize_with_readme: True
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create branch {{ gitlab_branch }}
|
|
|
|
community.general.gitlab_branch:
|
|
|
|
api_url: https://gitlab.com
|
|
|
|
api_token: secret_access_token
|
|
|
|
project: "{{ gitlab_project_name }}"
|
|
|
|
branch: "{{ gitlab_branch }}"
|
|
|
|
ref_branch: main
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create branch {{ gitlab_branch }} ( Idempotency test )
|
|
|
|
community.general.gitlab_branch:
|
|
|
|
api_url: https://gitlab.com
|
|
|
|
api_token: secret_access_token
|
|
|
|
project: "{{ gitlab_project_name }}"
|
|
|
|
branch: "{{ gitlab_branch }}"
|
|
|
|
ref_branch: main
|
|
|
|
state: present
|
|
|
|
register: create_branch
|
|
|
|
|
|
|
|
- name: Test module is idempotent
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- create_branch is not changed
|
|
|
|
|
|
|
|
- name: Cleanup branch {{ gitlab_branch }}
|
|
|
|
community.general.gitlab_branch:
|
|
|
|
api_url: https://gitlab.com
|
|
|
|
api_token: secret_access_token
|
|
|
|
project: "{{ gitlab_project_name }}"
|
|
|
|
branch: "{{ gitlab_branch }}"
|
|
|
|
state: absent
|
|
|
|
register: delete_branch
|
|
|
|
|
|
|
|
- name: Test module is idempotent
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- delete_branch is changed
|
|
|
|
|
|
|
|
- name: Clean up {{ gitlab_project_name }}
|
|
|
|
gitlab_project:
|
|
|
|
server_url: "{{ gitlab_host }}"
|
|
|
|
validate_certs: False
|
|
|
|
login_token: "{{ gitlab_login_token }}"
|
|
|
|
name: "{{ gitlab_project_name }}"
|
|
|
|
state: absent
|