Skip to content

Commit 932c948

Browse files
committed
Reuse OCP cluster
This patch creates playbooks and roles to allow re-using OCP cluster in zuul CI jobs
1 parent 647d7d7 commit 932c948

5 files changed

Lines changed: 449 additions & 1 deletion

File tree

clean_openstack_deployment.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
- name: Clean OpenStack deployment
22
hosts: "{{ target_host | default('localhost') }}"
3-
gather_facts: false
43
tasks:
54
- name: Clean up OpenStack operators
65
vars:
76
cifmw_kustomize_deploy_keep_generated_crs: false
87
ansible.builtin.include_role:
98
name: kustomize_deploy
109
tasks_from: cleanup
10+
11+
- name: Remove logs and tests directories
12+
ansible.builtin.file:
13+
path: "{{ item }}"
14+
state: absent
15+
loop:
16+
- "/home/zuul/ci-framework-data/logs"
17+
- "/home/zuul/ci-framework-data/tests"

deploy-edpm-reuse.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
- name: Manage unique ID
3+
ansible.builtin.import_playbook: playbooks/unique-id.yml
4+
5+
- name: Reproducer prepare play
6+
hosts: "{{ cifmw_target_host | default('localhost') }}"
7+
gather_facts: true
8+
pre_tasks:
9+
- name: Prepare cleanup script
10+
ansible.builtin.include_role:
11+
name: reproducer
12+
tasks_from: configure_cleanup.yaml
13+
14+
- name: Run Openstack cleanup
15+
no_log: "{{ cifmw_nolog | default(true) | bool }}"
16+
async: "{{ 7200 + cifmw_test_operator_timeout | default(3600) }}" # 2h should be enough to deploy EDPM and rest for tests.
17+
poll: 20
18+
delegate_to: controller-0
19+
ansible.builtin.command:
20+
cmd: "/home/zuul/cleanup-architecture.sh"
21+
22+
- name: Inherit from parent scenarios if needed
23+
ansible.builtin.include_tasks:
24+
file: "ci/playbooks/tasks/inherit_parent_scenario.yml"
25+
26+
- name: Include common architecture parameter file
27+
when:
28+
- cifmw_architecture_scenario is defined
29+
- cifmw_architecture_scenario | length > 0
30+
ansible.builtin.include_vars:
31+
file: "scenarios/reproducers/va-common.yml"
32+
33+
- name: Run reproducer validations
34+
ansible.builtin.import_role:
35+
name: reproducer
36+
tasks_from: validations
37+
38+
- name: Gather OS facts
39+
ansible.builtin.setup:
40+
gather_subset:
41+
- "!all"
42+
- "!min"
43+
- "distribution"
44+
45+
- name: Tweak dnf configuration
46+
become: true
47+
community.general.ini_file:
48+
no_extra_spaces: true
49+
option: "{{ config.option }}"
50+
path: "/etc/dnf/dnf.conf"
51+
section: "{{ config.section | default('main') }}"
52+
state: "{{ config.state | default(omit) }}"
53+
value: "{{ config.value | default(omit) }}"
54+
mode: "0644"
55+
loop: "{{ cifmw_reproducer_dnf_tweaks }}"
56+
loop_control:
57+
label: "{{ config.option }}"
58+
loop_var: 'config'
59+
60+
- name: Install custom CA if needed
61+
ansible.builtin.import_role:
62+
name: install_ca
63+
64+
- name: Setup repositories via rhos-release if needed
65+
tags:
66+
- packages
67+
when:
68+
- ansible_facts['distribution'] == 'RedHat'
69+
- cifmw_reproducer_hp_rhos_release | bool
70+
vars:
71+
cifmw_repo_setup_output: /etc/yum.repos.d
72+
cifmw_repo_setup_rhos_release_args: "rhel"
73+
ansible.builtin.import_role:
74+
name: repo_setup
75+
tasks_from: rhos_release
76+
77+
roles:
78+
- role: ci_setup
79+
80+
- name: Prepare switches
81+
vars:
82+
cifmw_configure_switches: "{{ 'switches' in groups }}"
83+
ansible.builtin.import_playbook: playbooks/switches_config.yml
84+
85+
- name: Reproducer reuse run
86+
hosts: "{{ cifmw_target_host | default('localhost') }}"
87+
gather_facts: false
88+
tasks:
89+
- name: Run reproducer reuse playbook
90+
ansible.builtin.include_role:
91+
name: reproducer
92+
tasks_from: reuse_main
93+
94+
- name: Run deployment if instructed to
95+
when:
96+
- cifmw_deploy_architecture | default(false) | bool
97+
no_log: "{{ cifmw_nolog | default(true) | bool }}"
98+
async: "{{ 7200 + cifmw_test_operator_timeout | default(3600) }}" # 2h should be enough to deploy EDPM and rest for tests.
99+
poll: 20
100+
delegate_to: controller-0
101+
ansible.builtin.command:
102+
cmd: "/home/zuul/deploy-architecture.sh {{ cifmw_deploy_architecture_args | default('') }}"

roles/kustomize_deploy/tasks/cleanup.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
reverse |
3535
selectattr('build_output', 'defined') |
3636
map(attribute='build_output') |
37+
map('basename') |
3738
list
3839
}}
3940
_stages_crs_path: >-
@@ -48,10 +49,14 @@
4849
- "{{ cifmw_kustomize_deploy_metallb_dest_file }}"
4950
- "{{ cifmw_kustomize_deploy_kustomizations_dest_dir }}/openstack.yaml"
5051
- "{{ cifmw_kustomize_deploy_olm_dest_file }}"
52+
_external_dns_crs:
53+
- /home/zuul/ci-framework-data/artifacts/manifests/cifmw_external_dns/ceph-local-dns.yml
54+
- /home/zuul/ci-framework-data/artifacts/manifests/cifmw_external_dns/ceph-local-cert.yml
5155
register: _cifmw_kustomize_files
5256
ansible.builtin.set_fact:
5357
cifmw_kustomize_deploy_crs_to_delete: >-
5458
{{
59+
_external_dns_crs +
5560
_stages_crs_path +
5661
_operators_crs
5762
}}
@@ -72,6 +77,10 @@
7277
wait: true
7378
wait_timeout: 600
7479
loop: "{{ _cifmw_kustomize_files.results }}"
80+
register: _cleanup_results
81+
until: "_cleanup_results is success"
82+
retries: 3
83+
delay: 120
7584
when:
7685
- item.stat.exists
7786
- not cifmw_kustomize_deploy_generate_crs_only
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
- name: Configure cleanup
3+
delegate_to: controller-0
4+
block:
5+
- name: Discover and expose CI Framework path on remote node
6+
tags:
7+
- always
8+
vars:
9+
default_path: >-
10+
{{
11+
cifmw_reproducer_default_repositories |
12+
selectattr('src', 'match', '^.*/ci[_\-]framework$') |
13+
map(attribute='dest') | first
14+
}}
15+
custom_path: >-
16+
{{
17+
cifmw_reproducer_repositories |
18+
selectattr('src', 'match', '^.*/ci-framework$') |
19+
map(attribute='dest')
20+
}}
21+
_path: >-
22+
{{
23+
(custom_path | length > 0) |
24+
ternary(custom_path | first, default_path)
25+
}}
26+
ansible.builtin.set_fact:
27+
_cifmw_reproducer_framework_location: >-
28+
{{
29+
(_path is match('.*/ci-framework/?$')) |
30+
ternary(_path, [_path, 'ci-framework'] | path_join)
31+
}}
32+
33+
- name: Push cleanup script
34+
vars:
35+
run_directory: "{{ _cifmw_reproducer_framework_location }}"
36+
exports:
37+
ANSIBLE_LOG_PATH: "~/ansible-cleanup-architecture.log"
38+
default_extravars:
39+
- "@~/ci-framework-data/parameters/reproducer-variables.yml"
40+
- "@~/ci-framework-data/parameters/openshift-environment.yml"
41+
- "@~/ci-framework-data/artifacts/parameters/openshift-login-params.yml"
42+
extravars: "{{ cifmw_reproducer_play_extravars }}"
43+
playbook: "clean_openstack_deployment.yaml"
44+
ansible.builtin.template:
45+
dest: "/home/zuul/cleanup-architecture.sh"
46+
src: "script.sh.j2"
47+
mode: "0755"
48+
owner: "zuul"
49+
group: "zuul"
50+
51+
- name: Rotate some logs
52+
tags:
53+
- always
54+
ansible.builtin.include_tasks: rotate_log.yml
55+
loop:
56+
- ansible-cleanup-architecture.log

0 commit comments

Comments
 (0)