From 6ca0bb7bd6164c2a0f4f5b8d59fa6f1235c8cdfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Fri, 9 Sep 2022 21:13:38 +0000 Subject: [PATCH] [CI] Optimise ovs setup Change-Id: I28ec8e02054ea75efffe472672ff3ed46c6f2cf7 --- playbooks/openvswitch.yml | 41 ------------------- playbooks/tenks-deploy-teardown/run.yml | 21 +++++----- .../tasks/ensure_openvswitch.yml | 23 +++++++++++ .../tenks-deploy-teardown/vars/Debian.yml | 2 + .../tenks-deploy-teardown/vars/RedHat.yml | 2 + .../tenks-deploy-teardown/vars/common.yml | 2 + 6 files changed, 40 insertions(+), 51 deletions(-) delete mode 100644 playbooks/openvswitch.yml create mode 100644 playbooks/tenks-deploy-teardown/tasks/ensure_openvswitch.yml create mode 100644 playbooks/tenks-deploy-teardown/vars/Debian.yml create mode 100644 playbooks/tenks-deploy-teardown/vars/RedHat.yml diff --git a/playbooks/openvswitch.yml b/playbooks/openvswitch.yml deleted file mode 100644 index 7d5d091..0000000 --- a/playbooks/openvswitch.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- hosts: hypervisors - vars: - ansible_become: true - tasks: - - block: - - name: Install the Delorean repositories - get_url: - url: "{{ item }}" - dest: /etc/yum.repos.d/ - with_items: - - "https://trunk.rdoproject.org/centos{{ ansible_facts.distribution_major_version }}-master/consistent/delorean.repo" - - "https://trunk.rdoproject.org/centos{{ ansible_facts.distribution_major_version }}-master/delorean-deps.repo" - - - name: Install Open vSwitch - package: - name: openvswitch - - - name: Start openvswitch service - service: - name: openvswitch - state: started - when: - - ansible_facts.os_family == "RedHat" - - - block: - - name: Install packages - package: - name: "{{ item }}" - register: result - until: result is success - retries: 3 - with_items: - - openvswitch-switch - - openvswitch-common - - - name: Start openvswitch service - service: - name: openvswitch-switch - state: started - when: ansible_facts.os_family == "Debian" diff --git a/playbooks/tenks-deploy-teardown/run.yml b/playbooks/tenks-deploy-teardown/run.yml index 0c742ce..8d11fc1 100644 --- a/playbooks/tenks-deploy-teardown/run.yml +++ b/playbooks/tenks-deploy-teardown/run.yml @@ -6,16 +6,17 @@ - name: Include common variables include_vars: common.yml - - name: Install Open vSwitch - shell: - cmd: >- - {{ ansible_playbook_bin }} -vvv - --inventory ansible/inventory - --extra-vars=@{{ tenks_overrides_path }} - playbooks/openvswitch.yml > {{ logs_dir }}/ansible/tenks-deploy - chdir: "{{ tenks_src_dir }}" - environment: - ANSIBLE_ROLES_PATH: "{{ tenks_src_dir }}/ansible/roles" + - name: Include OS-specific variables + include_vars: "{{ item }}" + with_first_found: + - files: + - "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml" + - "{{ ansible_facts.distribution }}.yml" + - "{{ ansible_facts.os_family }}.yml" + skip: true + + - name: Ensure Open vSwitch is set up + include_tasks: tasks/ensure_openvswitch.yml when: bridge_type == 'openvswitch' - name: Deploy tenks cluster diff --git a/playbooks/tenks-deploy-teardown/tasks/ensure_openvswitch.yml b/playbooks/tenks-deploy-teardown/tasks/ensure_openvswitch.yml new file mode 100644 index 0000000..2f7860c --- /dev/null +++ b/playbooks/tenks-deploy-teardown/tasks/ensure_openvswitch.yml @@ -0,0 +1,23 @@ +--- +- name: Install the Delorean dependencies repository + become: true + get_url: + url: "https://trunk.rdoproject.org/centos{{ ansible_facts.distribution_major_version }}-master/delorean-deps.repo" + dest: /etc/yum.repos.d/ + when: + - ansible_facts.os_family == "RedHat" + +- name: Install Open vSwitch + become: true + package: + name: "{{ openvswitch_package_name }}" + state: present + register: result + until: result is success + retries: 3 + +- name: Start Open vSwitch service + become: true + service: + name: "{{ openvswitch_service_name }}" + state: started diff --git a/playbooks/tenks-deploy-teardown/vars/Debian.yml b/playbooks/tenks-deploy-teardown/vars/Debian.yml new file mode 100644 index 0000000..7a6d322 --- /dev/null +++ b/playbooks/tenks-deploy-teardown/vars/Debian.yml @@ -0,0 +1,2 @@ +--- +openvswitch_package_name: openvswitch-switch diff --git a/playbooks/tenks-deploy-teardown/vars/RedHat.yml b/playbooks/tenks-deploy-teardown/vars/RedHat.yml new file mode 100644 index 0000000..1f89753 --- /dev/null +++ b/playbooks/tenks-deploy-teardown/vars/RedHat.yml @@ -0,0 +1,2 @@ +--- +openvswitch_package_name: openvswitch diff --git a/playbooks/tenks-deploy-teardown/vars/common.yml b/playbooks/tenks-deploy-teardown/vars/common.yml index d05a365..e3160a7 100644 --- a/playbooks/tenks-deploy-teardown/vars/common.yml +++ b/playbooks/tenks-deploy-teardown/vars/common.yml @@ -13,3 +13,5 @@ config_dir: "{{ ansible_facts.env.HOME ~ '/' ~ 'tenks-config' }}" tenks_overrides_path: "{{ config_dir ~ '/' ~ 'tenks-overrides.yml' }}" tenks_requirements_overrides_path: "{{ tenks_src_dir }}/requirements-overrides.yml" logs_dir: "/tmp/logs" + +openvswitch_service_name: "{{ openvswitch_package_name }}"