From 3cee97deee31bb86e5503d85d4dbc8fe45705964 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 24 Mar 2020 15:15:56 -0500 Subject: [PATCH] Normalize how we run validations This change normalizes how we execute validations by ensuring all validations calls are running via a shell command and sourcing the `stackrc` file; this is due to validations not being completely compatible with the OSC clouds config. All validations will now run when the `run_validations` is set to true. This ensures that the playbook will only execute validations when instructed to. Change-Id: Ie1b0c739dc08023a1bba7a98292a8c570b8a2a9c Signed-off-by: Kevin Carter --- .../playbooks/cli-baremetal-bios-apply.yaml | 1 - .../playbooks/cli-baremetal-bios-reset.yaml | 1 - .../playbooks/cli-baremetal-clean.yaml | 7 ---- .../playbooks/cli-baremetal-introspect.yaml | 28 +++++++++++-- .../playbooks/cli-baremetal-raid.yaml | 1 - .../playbooks/cli-deploy-deployment-plan.yaml | 41 ++++++++++++------- 6 files changed, 51 insertions(+), 28 deletions(-) diff --git a/tripleo_ansible/playbooks/cli-baremetal-bios-apply.yaml b/tripleo_ansible/playbooks/cli-baremetal-bios-apply.yaml index 57e05519c..8f477fa03 100644 --- a/tripleo_ansible/playbooks/cli-baremetal-bios-apply.yaml +++ b/tripleo_ansible/playbooks/cli-baremetal-bios-apply.yaml @@ -21,7 +21,6 @@ gather_facts: "{{ (tripleo_target_host is defined) | ternary(true, false) }}" any_errors_fatal: true vars: - run_validations: false concurrency: 20 max_retries: 2 node_timeout: 1200 diff --git a/tripleo_ansible/playbooks/cli-baremetal-bios-reset.yaml b/tripleo_ansible/playbooks/cli-baremetal-bios-reset.yaml index b9ac2f242..8eccfc760 100644 --- a/tripleo_ansible/playbooks/cli-baremetal-bios-reset.yaml +++ b/tripleo_ansible/playbooks/cli-baremetal-bios-reset.yaml @@ -21,7 +21,6 @@ gather_facts: "{{ (tripleo_target_host is defined) | ternary(true, false) }}" any_errors_fatal: true vars: - run_validations: false concurrency: 20 max_retries: 2 node_timeout: 1200 diff --git a/tripleo_ansible/playbooks/cli-baremetal-clean.yaml b/tripleo_ansible/playbooks/cli-baremetal-clean.yaml index da47c0f8a..90554c3a9 100644 --- a/tripleo_ansible/playbooks/cli-baremetal-clean.yaml +++ b/tripleo_ansible/playbooks/cli-baremetal-clean.yaml @@ -34,13 +34,6 @@ - node_uuids is undefined tasks: - # Pre-cleaning validation - - name: Run Validations - command: >- - openstack --os-cloud undercloud tripleo validator run --group "pre-clean" - when: - - run_validations | bool - - name: Set node_uuids_clean fact set_fact: node_uuids_clean: "{{ node_uuids }}" diff --git a/tripleo_ansible/playbooks/cli-baremetal-introspect.yaml b/tripleo_ansible/playbooks/cli-baremetal-introspect.yaml index 3c3baa98e..5b4772653 100644 --- a/tripleo_ansible/playbooks/cli-baremetal-introspect.yaml +++ b/tripleo_ansible/playbooks/cli-baremetal-introspect.yaml @@ -57,11 +57,33 @@ }}" # Pre-introspection validation - - name: Run Validations - command: > - openstack tripleo validator run --group "pre-introspection" + - name: Validations block when: - run_validations | bool + block: + - name: Check if validation enabled + set_fact: + validations_enabled: "{{ lookup('hiera', 'tripleo_validations_enabled') }}" + run_once: true + become: true + + # Pre-introspection validation + # NOTE(cloudnull): The stackrc file is sourced because validations are not + # 100% compatible with clouds.yaml at this time. + - name: Run Validations + shell: |- + source "{{ ansible_home }}/stackrc" + openstack --os-cloud undercloud tripleo validator run --group "pre-introspection" + when: + - validations_enabled | bool + + - name: Fail if validations are disabled + fail: + msg: >- + Run validations were enabled but via hiera information disabled. + Check the configuration and try again. + when: + - not (validations_enabled | bool) # Introspect nodes - name: Start baremetal introspection diff --git a/tripleo_ansible/playbooks/cli-baremetal-raid.yaml b/tripleo_ansible/playbooks/cli-baremetal-raid.yaml index 35e4d4c38..8d4a67739 100644 --- a/tripleo_ansible/playbooks/cli-baremetal-raid.yaml +++ b/tripleo_ansible/playbooks/cli-baremetal-raid.yaml @@ -21,7 +21,6 @@ gather_facts: "{{ (tripleo_target_host is defined) | ternary(true, false) }}" any_errors_fatal: true vars: - run_validations: false concurrency: 20 max_retries: 2 node_timeout: 1200 diff --git a/tripleo_ansible/playbooks/cli-deploy-deployment-plan.yaml b/tripleo_ansible/playbooks/cli-deploy-deployment-plan.yaml index 3f409abff..af54f90d9 100644 --- a/tripleo_ansible/playbooks/cli-deploy-deployment-plan.yaml +++ b/tripleo_ansible/playbooks/cli-deploy-deployment-plan.yaml @@ -35,22 +35,33 @@ - (tripleo_target_host is defined) | ternary('ssh', 'local') == 'local' tasks: - - name: Check if validation enabled - command: > - hiera tripleo_validations_enabled - register: validations_enabled - become: true - - - name: Run Validations - # 1. tripleo-validations does not work with clouds.yaml - # 2. Ignore errors as certain validations in 'pre-deployment' - # group i.e tls-everywhere-pre-deployment.yaml would fail. - shell: | - source "{{ ansible_home }}/stackrc" - openstack tripleo validator run --group "pre-deployment" + - name: Validations block when: - - validations_enabled.stdout | bool - ignore_errors: true + - run_validations | bool + block: + - name: Check if validation enabled + set_fact: + validations_enabled: "{{ lookup('hiera', 'tripleo_validations_enabled') }}" + run_once: true + become: true + + # Pre-deployment validation + # NOTE(cloudnull): The stackrc file is sourced because validations are not + # 100% compatible with clouds.yaml at this time. + - name: Run Validations + shell: |- + source "{{ ansible_home }}/stackrc" + openstack --os-cloud undercloud tripleo validator run --group "pre-deployment" + when: + - validations_enabled | bool + + - name: Fail if validations are disabled + fail: + msg: >- + Run validations were enabled but via hiera information disabled. + Check the configuration and try again. + when: + - not (validations_enabled | bool) - name: Prepare Container images and update plan tripleo_image_params_prepare: