diff --git a/.gitignore b/.gitignore index e85cb22..480f078 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +venv/ infra_config.yml -openstack.py +inventory/openstack.py .tox diff --git a/README.md b/README.md index a426ad1..070e554 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ Instructions ============ -1. Run ``bash setup_env.sh`` -2. Run ``source /opt/stack/ansible/hacking/env-setup`` +1. Run ``source setup_env.sh`` 3. Source your OpenStack cloud environment variables rc file 3. Run ``cp infra_config.yml.sample infra_config.yml`` 4. Edit infra_config.yml and put your environment values diff --git a/run.sh b/run.sh index 02b1643..b162996 100755 --- a/run.sh +++ b/run.sh @@ -1,3 +1,3 @@ #!/bin/bash ansible-playbook -i hosts provision_infra_servers.yml -e "@infra_config.yml" -ansible-playbook -i /opt/stack/ansible/contrib/inventory/openstack.py site.yml -e "@infra_config.yml" +ansible-playbook -i inventory/openstack.py site.yml -e "@infra_config.yml" diff --git a/setup_env.sh b/setup_env.sh index 659cd66..887eb78 100755 --- a/setup_env.sh +++ b/setup_env.sh @@ -1,53 +1,21 @@ #!/bin/bash -set -e -if [ -x '/usr/bin/apt-get' ]; then - if ! $(git --version &>/dev/null) ; then - sudo -H apt-get -y install git - fi - if ! $(pip -v &>/dev/null); then - sudo -H apt-get -y install python-pip - fi -elif [ -x '/usr/bin/yum' ]; then - if ! $(git --version &>/dev/null); then - sudo -H yum -y install git - fi - if ! $(pip -v &>/dev/null); then - sudo -H yum -y install python-pip - fi -else - echo "ERROR: Supported package manager not found. Supported: apt,yum" +# Install virtualenv package if not installed +if [ ! -f /usr/bin/pip ]; then + sudo -E apt-get install python-pip fi -sudo -E pip install -r "$(dirname $0)/requirements.txt" +# Create infra-ansible virtual environment +pip install virtualenv +virtualenv venv +source venv/bin/activate +pip install -r requirements.txt -u=$(whoami) -g=$(groups | awk '{print $1}') - -if [ ! -d /opt/stack ]; then - mkdir -p /opt/stack || (sudo mkdir -p /opt/stack) -fi -sudo -H chown -R $u:$g /opt/stack -cd /opt/stack - -if [ ! -d ansible ]; then - git clone https://github.com/ansible/ansible.git --recursive -else - cd ansible - git checkout devel - git pull --rebase - git submodule update --init --recursive - git fetch - # Temporary direct checkout of devel due to broken modules until - # the submodules pointers get updated in the core ansible repo. - cd lib/ansible/modules/core - git checkout devel +# Create inventory folder +if [ ! -d inventory ]; then + mkdir inventory fi -echo -echo "If your using this script directly, execute the" -echo "following commands to update your shell." -echo -echo "source env-vars" -echo "source /opt/stack/ansible/hacking/env-setup" -echo +# Install Ansible openstack inventory +/usr/bin/wget -N https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/openstack.py -O inventory/openstack.py +chmod +x inventory/openstack.py