-
Notifications
You must be signed in to change notification settings - Fork 39
/
main.yml
77 lines (66 loc) · 2.69 KB
/
main.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
---
- name: "Git clone operator-registry repo with the initializer command"
git:
repo: 'https://github.com/operator-framework/operator-registry.git'
dest: /tmp/operator-registry
version: "{{ operator_registry_branch }}"
force: true
- name: "Remove the previous catalog database file if exists"
file:
path: "/tmp/operator-registry/local.db"
state: absent
- name: "Download the production bundle catalog manifests"
shell: "{{ oc_bin_path }} adm catalog build --appregistry-org={{ production_quay_namespace }} --from=scratch"
register: catalog_manifests_dir_result
retries: 5
delay: 10
until: catalog_manifests_dir_result.rc == 0
no_log: true
- name: "Set catalog manifests directory"
set_fact:
catalog_manifests_dir: "{{ catalog_manifests_dir_result.stderr_lines[0].split('dir=', 1)[-1].split(' ')[0] }}"
when:
- catalog_manifests_dir_result.stderr_lines is defined
- catalog_manifests_dir_result.stderr_lines|length > 0
- name: "Remove the operator directory from the production bundle if exists"
file:
path: "{{ catalog_manifests_dir }}/{{ package_name }}"
state: absent
- name: "Create the empty operator directory"
file:
path: "{{ catalog_manifests_dir }}/{{ package_name }}"
state: directory
mode: o+rwx
- name: "Copy the testing operator metadata to the production catalog bundle"
shell: "cp -R {{ operator_dir }}/* {{ catalog_manifests_dir }}/{{ package_name }}"
- name: "Run the catalog initializer on the modified production catalog bundle"
shell: "{{ go_bin_path }} run -mod=vendor -tags=json1 ./cmd/initializer/main.go --manifests {{ catalog_manifests_dir }} --output local.db 2>&1"
register: catalog_initializer_result
args:
chdir: "/tmp/operator-registry"
ignore_errors: true
- name: "Output the catalog initialization log to a debug file"
copy:
content: "{{ catalog_initializer_result.stdout }}"
dest: "{{ work_dir }}/catalog-init-debug-{{ operator_registry_branch }}.txt"
mode: o+rwx
when:
- catalog_initializer_result.stdout|length > 0
- name: "Output the catalog initialization return code to a debug file"
copy:
content: "{{ catalog_initializer_result.rc }}"
dest: "{{ work_dir }}/catalog-init-rc-{{ operator_registry_branch }}.txt"
mode: o+rwx
when:
- catalog_initializer_result.rc is defined
- name: "Fail if the operator didn't satisfy the catalog initialization test"
fail:
msg: 'Catalog initialization test failed, check catalog-init-debug.txt for more details'
when:
- check_initializer_result|bool
- catalog_initializer_result.rc != 0
- name: "Remove the catalog manifest directory"
file:
path: "{{ catalog_manifests_dir }}"
state: absent
when: run_cleanup|bool