generated from opdev/new-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 11
/
install.yml
118 lines (118 loc) · 4.08 KB
/
install.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
- name: Generate full namespace
ansible.builtin.set_fact:
install_namespace: "{{ manifest_data.packageName | sha1 | truncate(8, False, '', 0) }}-{{ item | truncate(1, False, '', 0) | lower }}"
- name: Generate target namespace
ansible.builtin.set_fact:
target_namespace: "{{ (item not in ['OwnNamespace']) | ternary([install_namespace, 'ns1'] | join('-'), install_namespace) }}"
- name: Create main namespace
kubernetes.core.k8s:
name: "{{ install_namespace }}"
api_version: v1
kind: Namespace
definition:
metadata:
labels:
opdev: opcap
state: present
- name: Create additional namespace - Not OwnNamespace
kubernetes.core.k8s:
name: "{{ target_namespace }}"
api_version: v1
kind: Namespace
definition:
metadata:
labels:
opdev: opcap
state: present
when: item not in ["OwnNamespace"]
- name: Create operator group in kubernetes.core.k8s
kubernetes.core.k8s:
state: present
namespace: "{{ install_namespace }}"
resource_definition: "{{ lookup('template', 'templates/operator-group.yml.j2', template_vars=dict(install_mode=item)) }}"
- name: Create Subscription for operator
kubernetes.core.k8s:
state: present
namespace: "{{ install_namespace }}"
resource_definition: "{{ lookup('template', 'templates/subscription.yml.j2', template_vars=dict(install_mode=item)) }}"
- name: Get Current CSV
kubernetes.core.k8s_info:
namespace: "{{ install_namespace }}"
name: "{{ [channel.name, manifest_data.packageName, item | lower, 'subscription'] | join('-') }}"
api_version: operators.coreos.com/v1alpha1
kind: Subscription
register: subscription
until: subscription.resources[0].status.currentCSV is defined
retries: 10
delay: 10
- name: Get CSV and report
block:
- name: Get CSV Completed
kubernetes.core.k8s_info:
namespace: "{{ install_namespace }}"
name: "{{ subscription.resources[0].status.currentCSV }}"
api_version: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
register: result
until: result.resources[0] is defined and result.resources[0].status.phase == "Succeeded"
retries: 30
delay: 10
failed_when: result.resources is not defined or result.resources | length == 0 or result.resources[0].status.phase != "Succeeded"
rescue:
- name: Set timeout
ansible.builtin.set_fact:
operator_timeout: true
- name: Run FIPS enabled tests
ansible.builtin.include_tasks: fips_assessment.yml
when: fips_assessment | default(false)
register: fips_results
- name: Create FIPS result
ansible.builtin.set_fact:
assessment_stat:
result: "{{ assessment_result | default('result not reported') }}"
package_name: "{{ package_name }}"
install_type: "{{ item }}"
when: fips_assessment | default(false)
- name: Push FIPS stats
ansible.builtin.set_stats:
data:
fips_assessments: "{{ omit if assessment_stat is not defined else [assessment_stat] }}"
when: fips_assessment | default(false)
- name: Create stat
ansible.builtin.set_fact:
package:
name: "{{ manifest_data.packageName }}"
channel: "{{ channel.name }}"
install_mode: "{{ item }}"
result: "{{ (operator_timeout | default(false)) | ternary('timeout', result.resources[0].status.phase | default('')) }}"
message: "{{ result.resources[0].status.message | default('') }}"
reason: "{{ result.resources[0].status.reason | default('') }}"
- name: Push stats
ansible.builtin.set_stats:
data:
operators: "{{ [package] }}"
- name: Clean up additional namespace - Not OwnNamespace
kubernetes.core.k8s:
name: "{{ target_namespace }}"
api_version: v1
kind: Namespace
definition:
metadata:
labels:
opdev: opcap
state: absent
wait: true
wait_timeout: 60
wait_sleep: 10
when:
- item not in ["OwnNamespace"]
- cleanup is defined and cleanup
- name: Clean up namespace
kubernetes.core.k8s:
api_version: v1
kind: Namespace
label_selectors:
- opdev=opcap
state: absent
when: cleanup is defined and cleanup