| 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: Cleanup GitLab Group |
| 17 |
gitlab_group: |
| 18 |
api_url: "{{ gitlab_host }}" |
| 19 |
validate_certs: false |
| 20 |
api_token: "{{ gitlab_login_token }}" |
| 21 |
name: ansible_test_group |
| 22 |
path: ansible_test_group |
| 23 |
state: absent |
| 24 |
|
| 25 |
- name: Create GitLab Group |
| 26 |
gitlab_group: |
| 27 |
api_url: "{{ gitlab_host }}" |
| 28 |
validate_certs: false |
| 29 |
api_token: "{{ gitlab_login_token }}" |
| 30 |
name: ansible_test_group |
| 31 |
path: ansible_test_group |
| 32 |
state: present |
| 33 |
register: gitlab_group_state |
| 34 |
|
| 35 |
- name: Test group created |
| 36 |
assert: |
| 37 |
that: |
| 38 |
- gitlab_group_state is changed |
| 39 |
|
| 40 |
|
| 41 |
- name: Create GitLab Group ( Idempotency test ) |
| 42 |
gitlab_group: |
| 43 |
api_url: "{{ gitlab_host }}" |
| 44 |
validate_certs: false |
| 45 |
api_token: "{{ gitlab_login_token }}" |
| 46 |
name: ansible_test_group |
| 47 |
path: ansible_test_group |
| 48 |
state: present |
| 49 |
register: gitlab_group_state_again |
| 50 |
|
| 51 |
- name: Test module is idempotent |
| 52 |
assert: |
| 53 |
that: |
| 54 |
- gitlab_group_state_again is not changed |
| 55 |
|
| 56 |
- name: Cleanup GitLab Group for Description Test |
| 57 |
gitlab_group: |
| 58 |
api_url: "{{ gitlab_host }}" |
| 59 |
validate_certs: false |
| 60 |
api_token: "{{ gitlab_login_token }}" |
| 61 |
name: ansible_test_group |
| 62 |
path: ansible_test_group |
| 63 |
state: absent |
| 64 |
|
| 65 |
- name: Create GitLab Group for Description Test |
| 66 |
gitlab_group: |
| 67 |
api_url: "{{ gitlab_host }}" |
| 68 |
validate_certs: false |
| 69 |
api_token: "{{ gitlab_login_token }}" |
| 70 |
name: ansible_test_group |
| 71 |
path: ansible_test_group |
| 72 |
description: My Test Group |
| 73 |
state: present |
| 74 |
register: gitlab_group_state_desc |
| 75 |
|
| 76 |
- name: Test group created with Description |
| 77 |
assert: |
| 78 |
that: |
| 79 |
- gitlab_group_state_desc.group.description == "My Test Group" |
| 80 |
|
| 81 |
- name: Cleanup GitLab Group for project_creation_level Test |
| 82 |
gitlab_group: |
| 83 |
api_url: "{{ gitlab_host }}" |
| 84 |
validate_certs: false |
| 85 |
api_token: "{{ gitlab_login_token }}" |
| 86 |
name: ansible_test_group |
| 87 |
path: ansible_test_group |
| 88 |
state: absent |
| 89 |
|
| 90 |
- name: Create GitLab Group for project_creation_level Test |
| 91 |
gitlab_group: |
| 92 |
api_url: "{{ gitlab_host }}" |
| 93 |
validate_certs: false |
| 94 |
api_token: "{{ gitlab_login_token }}" |
| 95 |
name: ansible_test_group |
| 96 |
path: ansible_test_group |
| 97 |
project_creation_level: noone |
| 98 |
state: present |
| 99 |
register: gitlab_group_state_pcl |
| 100 |
|
| 101 |
- name: Test group created with project_creation_level |
| 102 |
assert: |
| 103 |
that: |
| 104 |
- gitlab_group_state_pcl.group.project_creation_level == "noone" |
| 105 |
|
| 106 |
- name: Cleanup GitLab Group for require_two_factor_authentication Test |
| 107 |
gitlab_group: |
| 108 |
api_url: "{{ gitlab_host }}" |
| 109 |
validate_certs: false |
| 110 |
api_token: "{{ gitlab_login_token }}" |
| 111 |
name: ansible_test_group |
| 112 |
path: ansible_test_group |
| 113 |
state: absent |
| 114 |
|
| 115 |
- name: Create GitLab Group for project_creation_level Test |
| 116 |
gitlab_group: |
| 117 |
api_url: "{{ gitlab_host }}" |
| 118 |
validate_certs: false |
| 119 |
api_token: "{{ gitlab_login_token }}" |
| 120 |
name: ansible_test_group |
| 121 |
path: ansible_test_group |
| 122 |
require_two_factor_authentication: true |
| 123 |
state: present |
| 124 |
register: gitlab_group_state_rtfa |
| 125 |
|
| 126 |
- name: Test group created with project_creation_level |
| 127 |
assert: |
| 128 |
that: |
| 129 |
- gitlab_group_state_rtfa.group.require_two_factor_authentication == true |