Collection of Ansible playbooks to bring up an OpenStack Infra
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.

setup_env.sh 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. #
  3. # Install python pip & virtualenv packages & then create
  4. # a python virtualenv & install the infra-ansible dependencies in it
  5. # check platform prerequisites
  6. case $(uname) in
  7. Linux)
  8. # check if the apt-get executable is available
  9. if hash apt-get 2>/dev/null; then
  10. # check for & install the various packages
  11. hash pip 2>/dev/null || { sudo -E apt-get install -y python-pip; }
  12. [[ -z "$(dpkg -l python-dev | grep '^ii python-dev')" ]] && sudo -E apt-get install -y python-dev
  13. hash virtualenv 2>/dev/null || { sudo pip install virtualenv; }
  14. elif hash yum 2>/dev/null; then
  15. # on RHEL/CentOS, pip is installed during the virtualenv setup
  16. hash virtualenv 2>/dev/null || { sudo -E yum install -y python-virtualenv python-devel gcc gcc-c++; }
  17. hash wget 2>/dev/null || { sudo -E yum install -y wget; }
  18. else
  19. echo "ERROR: Zoinks, I only know about Debian and RHEL"
  20. exit 1
  21. fi
  22. ;;
  23. Darwin)
  24. hash pip 2>/dev/null || { echo "ERROR: pip isn't installed, please rectify this!" ; exit 1; }
  25. hash virtualenv 2>/dev/null || { sudo pip install virtualenv; }
  26. ;;
  27. esac
  28. # Create a fresh infra-ansible virtual environment
  29. [[ -e venv ]] && rm -rf venv
  30. virtualenv venv
  31. source venv/bin/activate
  32. pip install -r requirements.txt
  33. # Create inventory folder
  34. if [[ ! -d inventory ]]; then
  35. mkdir inventory
  36. fi
  37. # Install roles dependencies from requirements.yml
  38. ansible-galaxy install -r requirements.yml
  39. # Install Ansible openstack inventory
  40. wget https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/openstack.py -O inventory/openstack.py
  41. chmod +x inventory/openstack.py