System configuration for OpenStack Infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.0KB

  1. #!/bin/bash
  2. # Copyright 2014 Hewlett-Packard Development Company, L.P.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. # If updating the puppet system-config repo or installing puppet modules
  16. # fails then abort the puppet run as we will not get the results we
  17. # expect.
  18. set -e
  19. export ANSIBLE_LOG_PATH=/var/log/puppet_run_cloud_launcher.log
  20. SYSTEM_CONFIG=/opt/system-config
  21. ANSIBLE_PLAYBOOKS=$SYSTEM_CONFIG/playbooks
  22. # It's possible for connectivity to a server or manifest application to break
  23. # for indeterminate periods of time, so the playbooks should be run without
  24. # errexit
  25. set +e
  26. # We only send stats if running under cron
  27. UNDER_CRON=0
  28. while getopts ":c" arg; do
  29. case $arg in
  30. c)
  31. UNDER_CRON=1
  32. ;;
  33. esac
  34. done
  35. _START_TIME=$(date '+%s')
  36. echo "--- begin run @ $(date -Is) ---"
  37. # We need access to all-clouds
  38. export OS_CLIENT_CONFIG_FILE=/etc/openstack/all-clouds.yaml
  39. # Pass -i /dev/null to avoid the ansible-playbook run with all-clouds.yaml
  40. # being active messing with the normal inventory cache.
  41. /usr/bin/timeout -k 2m 120m /usr/local/bin/ansible-playbook -i /dev/null -f 1 \
  42. ${ANSIBLE_PLAYBOOKS}/run_cloud_launcher.yaml \
  43. -e@${ANSIBLE_PLAYBOOKS}/clouds_layouts.yml
  44. echo "--- end run @ $(date -Is) ---"
  45. # Only send stats under cron conditions
  46. if [[ ${UNDER_CRON} != 1 ]]; then
  47. return
  48. fi
  49. _CURRENT_TIME=$(date '+%s')
  50. _ELAPSED_MS=$(( (_CURRENT_TIME - _START_TIME) * 1000 ))
  51. echo "bridge.ansible.run_cloud_launcher:${_ELAPSED_MS}|ms" | \
  52. nc -w 1 -u graphite.opendev.org 8125