-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpre-run.yml
158 lines (136 loc) · 5.04 KB
/
pre-run.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
- name: Create example-cnf facts
set_fact:
ecd_sriov_networks:
- name: example-cnf-net1
count: 1
- name: example-cnf-net2
count: 1
ecd_cnf_namespace: "example-cnf"
- name: Get example-cnf component details from job.components
set_fact:
operator_version: "{{ item['version'] }}"
example_cnf_index_image: "{{ item['data']['url'] }}:{{ item['version'] }}"
operator_component_id: "{{ item['id'] }}"
with_items: "{{ hostvars.localhost.job_info.job.components }}"
when: item["type"] == "nfv-example-cnf-index"
- name: Check example-cnf change presence
block:
- name: Check if example-cnf is part of the change
stat:
path: "{{ dci_change_dir }}/example-cnf"
register: examplecnf_change_dir
- block:
- name: Generate versions
shell: 'JSON=$(ls ../example-cnf-[0-9]*.json); if [ -z "$JSON" ]; then JSON=../github.json; fi; ./generate-versions.sh {{ job_logs.path }}/versions.cfg pr$(jq -r .number $JSON).$(jq -r .head.sha $JSON|cut -c1-8)'
args:
executable: /bin/bash
chdir: "{{ dci_change_dir }}/example-cnf"
- name: Get index version
shell: ". {{ job_logs.path }}/versions.cfg && echo v${VERSIONS[nfv-example-cnf-index]}"
register: index_output
args:
executable: /bin/bash
chdir: "{{ dci_change_dir }}/example-cnf"
- name: Override index and app variables
set_fact:
operator_version: "{{ index_output.stdout }}"
example_cnf_index_image: "quay.io/rh-nfv-int/nfv-example-cnf-catalog:{{ index_output.stdout }}"
- name: 'Remove component from the job'
dci_job_component:
component_id: "{{ operator_component_id }}"
job_id: " {{ job_id }} "
state: absent
when: examplecnf_change_dir.stat.exists and examplecnf_change_dir.stat.isdir
when:
- dci_change_dir is defined
- name: Create the preflight_operators_to_certify variable
when:
- certify_operators | default(false) | bool
- example_cnf_index_image is defined
block:
- name: Get Catalog Data
ansible.builtin.shell:
cmd: >
set -e -o pipefail;
{{ opm_tool_path }} render
{{ example_cnf_index_image }} |
jq -r '.relatedImages[].image'
args:
executable: /bin/bash
register: catalog_data_cmd
retries: 1
delay: 5
until:
- catalog_data_cmd.rc == 0
- name: Create an empty preflight_operators_to_certify variable
ansible.builtin.set_fact:
preflight_operators_to_certify: []
- name: Populate the preflight_operators_to_certify variable
ansible.builtin.set_fact:
preflight_operators_to_certify: "{{ preflight_operators_to_certify + [dict(bundle_image=item, index_image=example_cnf_index_image)] }}"
when: '"bundle@" in item'
loop: "{{ catalog_data_cmd.stdout_lines }}"
- name: Display the prefight_operators_to_certify variable
ansible.builtin.debug:
msg: "{{ preflight_operators_to_certify }}"
- name: "Create CNF Namespace"
kubernetes.core.k8s:
state: present
definition:
apiVersion: v1
kind: Namespace
metadata:
name: "{{ ecd_cnf_namespace }}"
labels:
security.openshift.io/scc.podSecurityLabelSync: "false"
pod-security.kubernetes.io/enforce: "privileged"
pod-security.kubernetes.io/enforce-version: "latest"
- name: "Add CNF Namespace to the list of NS to get logs from"
set_fact:
ns_list: "{{ ns_list|default([]) + [ ecd_cnf_namespace ] }}"
- name: Set the CNF mandatory network policies
kubernetes.core.k8s:
state: present
definition: "{{ lookup('template', 'templates/network_policies_cnf_traffic.yml.j2') | from_yaml }}"
loop:
- "example-cnf-type=cnf-app"
- "example-cnf-type=pkt-gen"
- "example-cnf-type=pkt-gen-app"
- "control-plane=controller-manager"
loop_control:
loop_var: label
- name: Set network policies for openshift DNS, API and Istio
kubernetes.core.k8s:
state: present
definition: "{{ lookup('template', 'templates/network_policies_istio_dns_api_traffic.yml.j2') | from_yaml }}"
- name: Create ResourceQuotas for namespace
kubernetes.core.k8s:
state: present
definition: "{{ lookup('template', 'templates/resource_quota.yml.j2') | from_yaml }}"
- name: Create SRIOV Policies and networks
ansible.builtin.include_role:
name: redhatci.ocp.sriov_config
vars:
sriov_config_file: "{{ example_cnf_sriov_file }}"
- name: "Install required rpm packages"
package:
name:
- git
- make
- python3-openshift
- python3-pyyaml
- ansible-collection-community-kubernetes
state: latest
become: true
- name: Mirror catalog in disconnected environment
include_tasks: mirror-catalog.yml
when:
- dci_disconnected | default(false) | bool
- name: Deploy NFV Example CNF catalog
vars:
ecd_action: "catalog"
ecd_operator_version: "{{ operator_version }}"
include_role:
name: redhatci.ocp.example_cnf_deploy
...