#!/bin/bash 
set -e
export ANSIBLE_HOST_KEY_CHECKING=False

source ./$NECTAR_ALLOCATION-openrc.sh
openstack stack list

cd CICD

python3 ../scripts/make_inventory.py static $STACKNAME | tee ./files/inventory.$STACKNAME && chmod 755 ./files/inventory.$STACKNAME
grep -qv "I could not find any resouces tagged with project_name:" ./files/inventory.$STACKNAME   #fail if inventory file is empty
ansible -m ping -i files/inventory.$STACKNAME --key-file ../gc_key.pem all
ansible -i files/inventory.$STACKNAME --key-file ../gc_key.pem -a "sudo ls" all

#cd roles 
    #- "egrep -lRZ 'sudo: true' . | xargs -0 -l sed -i -e 's/sudo: true/become: true/g' "
#cd ..
