Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/gitlab_branch/tasks/main.yml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # Copyright (c) Ansible Project
8 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
9 # SPDX-License-Identifier: GPL-3.0-or-later
10
11 - name: Install required libs
12 pip:
13 name: python-gitlab
14 state: present
15
16 - name: Create {{ gitlab_project_name }}
17 gitlab_project:
18 server_url: "{{ gitlab_host }}"
19 validate_certs: false
20 login_token: "{{ gitlab_login_token }}"
21 name: "{{ gitlab_project_name }}"
22 initialize_with_readme: true
23 state: present
24
25 - name: Create branch {{ gitlab_branch }}
26 community.general.gitlab_branch:
27 api_url: https://gitlab.com
28 api_token: secret_access_token
29 project: "{{ gitlab_project_name }}"
30 branch: "{{ gitlab_branch }}"
31 ref_branch: main
32 state: present
33
34 - name: Create branch {{ gitlab_branch }} ( Idempotency test )
35 community.general.gitlab_branch:
36 api_url: https://gitlab.com
37 api_token: secret_access_token
38 project: "{{ gitlab_project_name }}"
39 branch: "{{ gitlab_branch }}"
40 ref_branch: main
41 state: present
42 register: create_branch
43
44 - name: Test module is idempotent
45 assert:
46 that:
47 - create_branch is not changed
48
49 - name: Cleanup branch {{ gitlab_branch }}
50 community.general.gitlab_branch:
51 api_url: https://gitlab.com
52 api_token: secret_access_token
53 project: "{{ gitlab_project_name }}"
54 branch: "{{ gitlab_branch }}"
55 state: absent
56 register: delete_branch
57
58 - name: Test module is idempotent
59 assert:
60 that:
61 - delete_branch is changed
62
63 - name: Clean up {{ gitlab_project_name }}
64 gitlab_project:
65 server_url: "{{ gitlab_host }}"
66 validate_certs: false
67 login_token: "{{ gitlab_login_token }}"
68 name: "{{ gitlab_project_name }}"
69 state: absent