From d4c5ca2aa05a3239d81f95a7cafff29fc1e22474 Mon Sep 17 00:00:00 2001 From: Mihnea Saracin Date: Thu, 2 Sep 2021 13:17:27 +0300 Subject: [PATCH] Fix Trident playbook The trident playbook was using a role which used an undefined variable named 'kubernetes_version'. We fix this by adding a role that will determine the 'kubernetes_version' before using it. Testing done: Ran install_netapp_backend.yml playbook and it passed successfully Closes-Bug: #1942318 Change-Id: Ie71b3b50a7667d2eaae7a002325b060d6130c26a Signed-off-by: Mihnea Saracin --- .../src/playbooks/install_netapp_backend.yml | 1 + .../common/get-kube-version/tasks/main.yml | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 playbookconfig/src/playbooks/roles/common/get-kube-version/tasks/main.yml diff --git a/playbookconfig/src/playbooks/install_netapp_backend.yml b/playbookconfig/src/playbooks/install_netapp_backend.yml index 28c367287..5e306760e 100644 --- a/playbookconfig/src/playbooks/install_netapp_backend.yml +++ b/playbookconfig/src/playbooks/install_netapp_backend.yml @@ -13,6 +13,7 @@ # Main play roles: - { role: common/prepare-env } + - { role: common/get-kube-version, become: yes } - { role: roles/common/push-docker-images, become: yes } - { role: roles/k8s-storage-backends/snapshot-controller, become: yes } - { role: roles/k8s-storage-backends/netapp, become: yes } diff --git a/playbookconfig/src/playbooks/roles/common/get-kube-version/tasks/main.yml b/playbookconfig/src/playbooks/roles/common/get-kube-version/tasks/main.yml new file mode 100644 index 000000000..ee89c77b7 --- /dev/null +++ b/playbookconfig/src/playbooks/roles/common/get-kube-version/tasks/main.yml @@ -0,0 +1,17 @@ +--- +# +# Copyright (c) 2021 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +- block: + - name: Get kubernetes_version from the DB + shell: echo "select kubeadm_version from kube_cmd_versions" | psql -qAt -d sysinv + register: kube_ver_select_result + become_user: postgres + + - name: Set kubernetes_version to the value from DB + set_fact: + kubernetes_version: "{{ kube_ver_select_result.stdout_lines[0] }}" + + when: kubernetes_version is not defined