Guest User

Untitled

a guest
Mar 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #script to recursively travel a dir of n levels
  4.  
  5. function traverse() {
  6.  
  7. for file in `ls $1`
  8. do
  9. #current=${1}{$file}
  10. if [ ! -d ${1}${file} ] ; then
  11. echo ''
  12. else
  13.  
  14. echo -e "${GREEN}==== Deploying TF in ${1}${file} ====${NC}"
  15. cd ${1}/${file}
  16.  
  17. if ls | grep -q .tf;
  18. then
  19. terraform init
  20. terraform plan
  21. terraform apply
  22. fi
  23.  
  24. echo -e "${GREEN}==== Done deploying TF in ${1}${file} ====${NC}"
  25.  
  26. traverse "${1}/${file}"
  27. fi
  28. done
  29. }
  30.  
  31.  
  32. GREEN='\033[0;32m'
  33. NC='\033[0;0m'
  34. export PATH=$PATH:$(pwd)
  35.  
  36. echo -e "${GREEN}==== Deploying terraform ====${NC}"
  37.  
  38. traverse ../
  39.  
  40. for f in $(find ./ -name '*.yaml' -or -name '*.yml'); do kubectl apply -f $f --validate=false; done
  41. echo -e "${GREEN}==== Done deploying terraform ====${NC}"
  42. echo ''
Add Comment
Please, Sign In to add comment