Merge "Refactor setup_env.sh to use virtualenvs"
This commit is contained in:
commit
ab9554c77f
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
|
venv/
|
||||||
infra_config.yml
|
infra_config.yml
|
||||||
openstack.py
|
inventory/openstack.py
|
||||||
.tox
|
.tox
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
Instructions
|
Instructions
|
||||||
============
|
============
|
||||||
|
|
||||||
1. Run ``bash setup_env.sh``
|
1. Run ``source setup_env.sh``
|
||||||
2. Run ``source /opt/stack/ansible/hacking/env-setup``
|
|
||||||
3. Source your OpenStack cloud environment variables rc file
|
3. Source your OpenStack cloud environment variables rc file
|
||||||
3. Run ``cp infra_config.yml.sample infra_config.yml``
|
3. Run ``cp infra_config.yml.sample infra_config.yml``
|
||||||
4. Edit infra_config.yml and put your environment values
|
4. Edit infra_config.yml and put your environment values
|
||||||
|
2
run.sh
2
run.sh
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
ansible-playbook -i hosts provision_infra_servers.yml -e "@infra_config.yml"
|
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"
|
||||||
|
60
setup_env.sh
60
setup_env.sh
@ -1,53 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -x '/usr/bin/apt-get' ]; then
|
# Install virtualenv package if not installed
|
||||||
if ! $(git --version &>/dev/null) ; then
|
if [ ! -f /usr/bin/pip ]; then
|
||||||
sudo -H apt-get -y install git
|
sudo -E apt-get install python-pip
|
||||||
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"
|
|
||||||
fi
|
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)
|
# Create inventory folder
|
||||||
g=$(groups | awk '{print $1}')
|
if [ ! -d inventory ]; then
|
||||||
|
mkdir inventory
|
||||||
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
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
# Install Ansible openstack inventory
|
||||||
echo "If your using this script directly, execute the"
|
/usr/bin/wget -N https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/openstack.py -O inventory/openstack.py
|
||||||
echo "following commands to update your shell."
|
chmod +x inventory/openstack.py
|
||||||
echo
|
|
||||||
echo "source env-vars"
|
|
||||||
echo "source /opt/stack/ansible/hacking/env-setup"
|
|
||||||
echo
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user