#!/bin/bash

set -ux
set -o pipefail

### --start_docs
## Run pre-deployment validations negative tests
## =============================================

## Prepare Your Environment
## ------------------------

## * Source in the undercloud credentials.
## ::

source {{ val_working_dir }}/stackrc

# Use custom validation-specific formatter
export ANSIBLE_STDOUT_CALLBACK=validation_output
# Disable retry files to avoid messages like this:
# [Errno 13] Permission denied:
# u'/usr/share/openstack-tripleo-validations/validations/*.retry'
export ANSIBLE_RETRY_FILES_ENABLED=false

## * Generate ansible static inventory for tripleo-validations
## ::

ANSIBLE_INVENTORY_BIN=$(which tripleo-ansible-inventory)

{% if release == 'newton' %}
    export ANSIBLE_INVENTORY=${ANSIBLE_INVENTORY_BIN}
{% else %}
    ${ANSIBLE_INVENTORY_BIN} --static-inventory {{ validations_static_inventory }}
    export ANSIBLE_INVENTORY="{{ validations_static_inventory }}"
{% endif %}

# TODO(gchamoul) add negative tests for pre-deployment validations

## --stop_docs

