SHARE
TWEET

Untitled

a guest Jan 17th, 2019 254 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # tower-job
  4. #
  5. # Directions
  6. #
  7. # install tower-cli
  8. #   sudo pip install tower-cli
  9. #
  10. # put this file in a root of your project
  11. #   {{ project_root }}/tower-job
  12. #
  13. # create a file ~/.tower-cli.cfg with contents:
  14. #
  15. #   [general]
  16. #   host = fqdn.yourhost.com
  17. #   username = your-username
  18. #   password = ssssshhhhhhhh
  19. #
  20. # add variables from your tower survey to a vars file. we'll use group_vars/tower-job.yml
  21. #   ---
  22. #   survey_env: "DEV"
  23. #   survey_version: "2.0"
  24. #   survey_mychart_customer: "bob"
  25. #
  26. # define your job template ID # from tower below
  27. #   job_template_id=574
  28. #
  29. # make this file exec
  30. #   chmod 755 tower-job
  31. #
  32. # then run it
  33. #   ./tower-job
  34.  
  35. tower_template_id=574
  36.  
  37. if [ ! -d 'group_vars' ]; then
  38.     echo "No group_vars found, run this out of root of project"; exit 1
  39. fi
  40.  
  41. tower-cli job launch --job-template=$tower_template_id --extra-vars="@group_vars/tower-job.yml" | tee tower-job.pid
  42.  
  43. job_id=$(cat tower-job.pid | tail -n2 | head -n1 | awk '{print $1}')
  44.  
  45. rm tower-job.pid
  46.  
  47. while [ $(tower-cli job list --status=running | grep $job_id | wc -l) -lt '1' ]; do
  48.     echo -n "-"; sleep 1;
  49. done;
  50.  
  51. echo
  52.  
  53. tower-cli job monitor $job_id
  54.  
  55. exit 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top