From bdaa7829df59b1730e070e7411d421f70421ab6f Mon Sep 17 00:00:00 2001 From: Pablo Rodriguez Nava Date: Mon, 29 Jul 2024 16:31:14 +0200 Subject: [PATCH] [reproducer] Call switches config if available --- docs/source/usage/01_usage.md | 1 + playbooks/switches_config.yml | 30 ++++++++++++++++++++++ reproducer.yml | 15 ++++++++--- roles/ci_setup/vars/main.yml | 1 + roles/ci_setup/vars/redhat.yml | 1 + roles/switch_config/tasks/junos_config.yml | 3 ++- 6 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 playbooks/switches_config.yml diff --git a/docs/source/usage/01_usage.md b/docs/source/usage/01_usage.md index 9c3abe58ac..74b10c8a16 100644 --- a/docs/source/usage/01_usage.md +++ b/docs/source/usage/01_usage.md @@ -67,6 +67,7 @@ are shared among multiple roles: - `cifmw_openshift_ingress_ip_address` (String) contains the OpenShift Ingress IP address. Note: it is computed internally and should not be user defined. - `cifmw_nolog`: (Bool) Toggle `no_log` value for selected tasks. Defaults to `true` (hiding those logs by default). - `cifmw_parent_scenario`: (String or List(String)) path to existing scenario/parameter file to inherit from. +- `cifmw_configure_switches`: (Bool) Specifies whether switches should be configured. Computes in `reproducer.yml` playbook. Defaults to `false`. ```{admonition} Words of caution :class: danger diff --git a/playbooks/switches_config.yml b/playbooks/switches_config.yml new file mode 100644 index 0000000000..aadf9c9545 --- /dev/null +++ b/playbooks/switches_config.yml @@ -0,0 +1,30 @@ +--- +- name: Switches configuration requirements + hosts: "{{ cifmw_target_host | default('localhost') }}" + gather_facts: false + pre_tasks: + # end_play will end this current playbook and go the the next + # imported play. + - name: Early playbook stop + when: + - not cifmw_configure_switches | default(true) + ansible.builtin.meta: end_play + tasks: + - name: Install required packages + delegate_to: localhost + ansible.builtin.pip: + name: + - paramiko + - ncclient + extra_args: --user + +- name: Switches configuration + hosts: switches + gather_facts: false + pre_tasks: + - name: Early playbook stop + when: + - not cifmw_configure_switches | default(true) + ansible.builtin.meta: end_play + roles: + - switch_config diff --git a/reproducer.yml b/reproducer.yml index 2ca9310f32..a680375020 100644 --- a/reproducer.yml +++ b/reproducer.yml @@ -1,6 +1,5 @@ --- - -- name: Reproducer Play +- name: Reproducer prepare play hosts: "{{ cifmw_target_host | default('localhost') }}" gather_facts: true pre_tasks: @@ -57,11 +56,19 @@ ansible.builtin.import_role: name: repo_setup tasks_from: rhos_release.yml - roles: - role: ci_setup - - role: reproducer +- name: Prepare switches + vars: + cifmw_configure_switches: "{{ 'switches' in groups }}" + ansible.builtin.import_playbook: playbooks/switches_config.yml + +- name: Reproducer run + hosts: "{{ cifmw_target_host | default('localhost') }}" + gather_facts: false + roles: + - role: reproducer post_tasks: - name: Allow traffic from OSP VMs to OSP API (needed for shiftstack) become: true diff --git a/roles/ci_setup/vars/main.yml b/roles/ci_setup/vars/main.yml index 3c6c758eb7..b439d587de 100644 --- a/roles/ci_setup/vars/main.yml +++ b/roles/ci_setup/vars/main.yml @@ -23,6 +23,7 @@ cifmw_ci_setup_packages: - bash-completion - make - tmux + - python3-pip # openshift client cifmw_ci_setup_openshift_client_download_uri: "https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp" diff --git a/roles/ci_setup/vars/redhat.yml b/roles/ci_setup/vars/redhat.yml index 077a9950a3..c251d42152 100644 --- a/roles/ci_setup/vars/redhat.yml +++ b/roles/ci_setup/vars/redhat.yml @@ -6,6 +6,7 @@ cifmw_ci_setup_packages: - make - tar - tmux + - python3-pip cifmw_ci_setup_rhel_rhsm_default_repos: - 'rhel-*-baseos-rpms' diff --git a/roles/switch_config/tasks/junos_config.yml b/roles/switch_config/tasks/junos_config.yml index 41a55c8e3d..4c266695ec 100644 --- a/roles/switch_config/tasks/junos_config.yml +++ b/roles/switch_config/tasks/junos_config.yml @@ -1,7 +1,8 @@ --- # Workaround since Ansible modules lock the database similar to `configure exclusive` -- name: "Random Duraion Pause" +- name: "Random duration pause" + delegate_to: localhost ansible.builtin.pause: seconds: "{{ 90 | random(step=6) }}"