#!/usr/bin/env bash [[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x set -euo pipefail contrib_dir=../../../../contrib/inventory echo "DEBUG: using ${contrib_dir}" export ANSIBLE_CONFIG=ansible.cfg export vcenter_host="${vcenter_host:-0.0.0.0}" export VMWARE_SERVER="${vcenter_host}" export VMWARE_USERNAME="${VMWARE_USERNAME:-user}" export VMWARE_PASSWORD="${VMWARE_PASSWORD:-pass}" VMWARE_CONFIG=${contrib_dir}/vmware_inventory.ini trap cleanup INT TERM EXIT # Remove default inventory config file if [ -f "${VMWARE_CONFIG}" ]; then echo "DEBUG: Creating backup of ${VMWARE_CONFIG}" cp "${VMWARE_CONFIG}" "${VMWARE_CONFIG}.bk" fi cat > "${VMWARE_CONFIG}" < /dev/null 2>&1 echo "Start new VCSIM server" curl "http://${vcenter_host}:5000/spawn?datacenter=1&cluster=1&folder=0" > /dev/null 2>&1 echo "Debugging new instances" curl "http://${vcenter_host}:5000/govc_find" # Get inventory ansible-playbook -i ./vmware_inventory.sh "./test_vmware_inventory.yml" --connection=local "$@" echo "DEBUG: Done"