Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/gitlab_deploy_key/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 state: present
23
24 - name: Cleanup deploy key to {{ gitlab_project_name }}
25 gitlab_deploy_key:
26 login_token: "{{ gitlab_login_token }}"
27 project: "{{ gitlab_project_name }}"
28 server_url: "{{ gitlab_host }}"
29 title: "{{ gitlab_project_name }}"
30 key: "{{ gitlab_deploy_key }}"
31 state: absent
32
33
34 - name: Add deploy key to {{ gitlab_project_name }}
35 gitlab_deploy_key:
36 login_token: "{{ gitlab_login_token }}"
37 project: "root/{{ gitlab_project_name }}"
38 server_url: "{{ gitlab_host }}"
39 title: "{{ gitlab_project_name }}"
40 key: "{{ gitlab_deploy_key }}"
41 state: present
42 register: deploy_key_status
43
44 - assert:
45 that:
46 - deploy_key_status is changed
47 - deploy_key_status.deploy_key.key == gitlab_deploy_key
48
49
50 - name: Update public key {{ gitlab_project_name }} (change expected)
51 gitlab_deploy_key:
52 login_token: "{{ gitlab_login_token }}"
53 project: "root/{{ gitlab_project_name }}"
54 server_url: "{{ gitlab_host }}"
55 title: "{{ gitlab_project_name }}"
56 key: "{{ gitlab_deploy_key_new }}"
57 state: present
58 register: deploy_key_status
59
60 - assert:
61 that:
62 - deploy_key_status is changed
63 - deploy_key_status.deploy_key.key == gitlab_deploy_key_new
64
65 - name: Update public key {{ gitlab_project_name }} (no change expected)
66 gitlab_deploy_key:
67 login_token: "{{ gitlab_login_token }}"
68 project: "root/{{ gitlab_project_name }}"
69 server_url: "{{ gitlab_host }}"
70 title: "{{ gitlab_project_name }}"
71 key: "{{ gitlab_deploy_key_new }}"
72 state: present
73 register: deploy_key_status
74
75 - assert:
76 that:
77 - not deploy_key_status.changed
78 - deploy_key_status.deploy_key.key == gitlab_deploy_key_new