Skip to content

Commit d2e1f18

Browse files
danpawlikevallesp
authored andcommitted
Drop nested ansible execution - e2e-collect-logs
We want to drop nested Ansible execution where it is possible. It is wrong, to execute sometimes 4 or 5 time nested Ansible. It makes debugging difficult, raise more complication and sometimes variable overwrite is just problematic. Depends-On: #3235 Depends-On: #3287 More: OSPRH-20006 Signed-off-by: Daniel Pawlik <[email protected]>
1 parent 9e3bb08 commit d2e1f18

File tree

3 files changed

+42
-30
lines changed

3 files changed

+42
-30
lines changed

ci/playbooks/e2e-collect-logs.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,25 @@
2020
- not cifmw_status.stat.exists
2121
ansible.builtin.meta: end_host
2222

23-
- name: Run log collection when zuul_log_collection
24-
hosts: "{{ cifmw_target_host | default(cifmw_zuul_target_host) | default('controller') }}"
25-
gather_facts: true
26-
tasks:
27-
- name: Run run_logs tasks from cifmw_setup
28-
ansible.builtin.command: >
29-
ansible localhost
30-
-m include_role
31-
-a "name=cifmw_setup tasks_from=run_logs.yml"
32-
-e "@scenarios/centos-9/base.yml"
33-
args:
34-
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework"
23+
- name: Read base centos-9 scenarios
24+
vars:
25+
provided_file: >
26+
{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/
27+
ci-framework/scenarios/centos-9/base.yml
28+
ansible.builtin.include_role:
29+
name: cifmw_helpers
30+
tasks_from: var_file.yml
31+
32+
- name: Run log collection
33+
ansible.builtin.import_role:
34+
name: cifmw_setup
35+
tasks_from: run_logs.yml
36+
tags:
37+
- logs
3538
environment:
3639
ANSIBLE_LOG_PATH: "{{ ansible_user_dir }}/ci-framework-data/logs/e2e-collect-logs-must-gather.log"
3740

38-
- name: "Run ci/playbooks/collect-logs.yml on CRC host"
41+
- name: "Run ci/playbooks/e2e-collect-logs.yml on CRC host"
3942
hosts: crc
4043
gather_facts: false
4144
tasks:

ci/playbooks/edpm/run.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
path: "{{ ansible_user_dir }}/ci-framework-data/artifacts/edpm-ansible.yml"
1616
register: edpm_file
1717

18+
###
19+
# Make cifmw general plugins available when nested Ansible executed
20+
- name: Make a symlink to local .ansible collection dir
21+
ansible.builtin.include_role:
22+
name: cifmw_helpers
23+
tasks_from: symlink_cifmw_collection.yml
24+
1825
- name: Run Podified EDPM deployment
1926
ansible.builtin.command:
2027
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework"

roles/cifmw_setup/tasks/run_logs.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@
66

77
- name: Try to load parameters files
88
block:
9-
- name: Check directory availability
10-
register: param_dir
11-
ansible.builtin.stat:
12-
path: "{{ cifmw_basedir }}/artifacts/parameters"
13-
14-
- name: Load parameters files
15-
when:
16-
- param_dir.stat.exists | bool
17-
ansible.builtin.include_vars:
18-
dir: "{{ cifmw_basedir }}/artifacts/parameters"
19-
always:
20-
- name: Set custom cifmw PATH reusable fact
21-
when:
22-
- cifmw_path is not defined
23-
ansible.builtin.set_fact:
24-
cifmw_path: "{{ ansible_user_dir }}/.crc/bin:{{ ansible_user_dir }}/.crc/bin/oc:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}"
25-
cacheable: true
9+
- name: Try to load parameters files
10+
block:
11+
# NOTE: We should not check, if the parameters dir exists
12+
# on remote host, due in later stage, we use "include_vars",
13+
# which is reading variable ONLY on localhost.
14+
# Ensure, that the directory exists on localhost before continue.
15+
- name: Read artifacts parameters dir and set as facts
16+
vars:
17+
provided_dir: "{{ cifmw_basedir }}/artifacts/parameters"
18+
ansible.builtin.include_role:
19+
name: cifmw_helpers
20+
tasks_from: var_dir.yml
21+
always:
22+
- name: Set custom cifmw PATH reusable fact
23+
when:
24+
- cifmw_path is not defined
25+
ansible.builtin.set_fact:
26+
cifmw_path: "{{ ansible_user_dir }}/.crc/bin:{{ ansible_user_dir }}/.crc/bin/oc:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}"
27+
cacheable: true
2628

2729
- name: Set destination folder for the logs
2830
ansible.builtin.set_fact:

0 commit comments

Comments
 (0)