Merge "Make ansible installation directory configurable"

This commit is contained in:
Jenkins 2016-06-08 18:38:38 +00:00 committed by Gerrit Code Review
commit 2d23513052
6 changed files with 52 additions and 9 deletions

View File

@ -122,10 +122,21 @@ If you are running the installation behind a proxy, export the
environment variables ``http_proxy`` and ``https_proxy`` so that environment variables ``http_proxy`` and ``https_proxy`` so that
Ansible will use these proxy settings. Ansible will use these proxy settings.
The below script ``env-setup.sh`` will install ansible and all of bifrost's
dependencies. You can configure the ansible installation location by setting
``ANSIBLE_INSTALL_ROOT`` environment variable. The default value will be
``/opt/stack``.
Note:
Only ansible installation location will be moved as part of the
environment variable. The other components will continue to be cloned under
``/opt/stack``
Then run:: Then run::
bash ./scripts/env-setup.sh bash ./scripts/env-setup.sh
source /opt/stack/ansible/hacking/env-setup source ${ANSIBLE_INSTALL_ROOT}/stack/ansible/hacking/env-setup
cd playbooks cd playbooks
The second part is an Ansible playbook that installs and configures ironic The second part is an Ansible playbook that installs and configures ironic

View File

@ -46,3 +46,19 @@ Edit the Vagrantfile:
Boot the VM with:: Boot the VM with::
vagrant up vagrant up
--------------------
Installation Options
--------------------
Ansible is installed within the VM directly from `source
<https://github.com/ansible/ansible.git>`_ or from the path set by
``ANSIBLE_GIT_URL``. You can modify the path of installation by setting
``ANSIBLE_INSTALL_ROOT`` environment variable. The default value is
``/opt/stack``. When set in the host, this variable will also be set as an
environment variable inside the VM for use by test scripts.
Note:
Only the ansible installation path is configurable at this point using
the enviroment variable. All other dependencies will still continue to cloned
under ``/opt/stack``.

View File

@ -6,6 +6,7 @@ ANSIBLE_GIT_URL=${ANSIBLE_GIT_URL:-https://github.com/ansible/ansible.git}
# issues with the stable branch. # issues with the stable branch.
# https://github.com/ansible/ansible-modules-core/issues/2804 # https://github.com/ansible/ansible-modules-core/issues/2804
ANSIBLE_GIT_BRANCH=${ANSIBLE_GIT_BRANCH:-v2.0.0.0-1} ANSIBLE_GIT_BRANCH=${ANSIBLE_GIT_BRANCH:-v2.0.0.0-1}
ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack}
function check_get_module () { function check_get_module () {
local file=${1} local file=${1}
@ -117,11 +118,11 @@ sudo -H -E ${PIP} install -r "$(dirname $0)/../requirements.txt"
u=$(whoami) u=$(whoami)
g=$(groups | awk '{print $1}') g=$(groups | awk '{print $1}')
if [ ! -d /opt/stack ]; then if [ ! -d ${ANSIBLE_INSTALL_ROOT} ]; then
mkdir -p /opt/stack || (sudo mkdir -p /opt/stack) mkdir -p ${ANSIBLE_INSTALL_ROOT} || (sudo mkdir -p ${ANSIBLE_INSTALL_ROOT})
fi fi
sudo -H chown -R $u:$g /opt/stack sudo -H chown -R $u:$g ${ANSIBLE_INSTALL_ROOT}
cd /opt/stack cd ${ANSIBLE_INSTALL_ROOT}
if [ ! -d ansible ]; then if [ ! -d ansible ]; then
git clone $ANSIBLE_GIT_URL --recursive -b $ANSIBLE_GIT_BRANCH git clone $ANSIBLE_GIT_URL --recursive -b $ANSIBLE_GIT_BRANCH
@ -152,7 +153,7 @@ check_get_module `pwd`/lib/ansible/modules/extras/cloud/openstack/os_ironic_insp
https://raw.githubusercontent.com/juliakreger/ansible-modules-extras/feature/os-ironic-inspect/cloud/openstack/os_ironic_inspect.py https://raw.githubusercontent.com/juliakreger/ansible-modules-extras/feature/os-ironic-inspect/cloud/openstack/os_ironic_inspect.py
if [ -n "${VENV-}" ]; then if [ -n "${VENV-}" ]; then
sudo -H -E ${PIP} install --upgrade /opt/stack/ansible sudo -H -E ${PIP} install --upgrade ${ANSIBLE_INSTALL_ROOT}/ansible
echo echo
echo "To use bifrost, do" echo "To use bifrost, do"
@ -166,6 +167,6 @@ else
echo "following commands to update your shell." echo "following commands to update your shell."
echo echo
echo "source env-vars" echo "source env-vars"
echo "source /opt/stack/ansible/hacking/env-setup" echo "source ${ANSIBLE_INSTALL_ROOT}/ansible/hacking/env-setup"
echo echo
fi fi

View File

@ -5,6 +5,7 @@ set -o pipefail
export PYTHONUNBUFFERED=1 export PYTHONUNBUFFERED=1
SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)" SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)"
BIFROST_HOME=$SCRIPT_HOME/.. BIFROST_HOME=$SCRIPT_HOME/..
ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack}
ENABLE_VENV="false" ENABLE_VENV="false"
USE_DHCP="false" USE_DHCP="false"
USE_VENV="false" USE_VENV="false"
@ -59,7 +60,7 @@ if [ ${USE_VENV} = "true" ]; then
ENABLE_VENV="true" ENABLE_VENV="true"
else else
$SCRIPT_HOME/env-setup.sh $SCRIPT_HOME/env-setup.sh
source /opt/stack/ansible/hacking/env-setup source ${ANSIBLE_INSTALL_ROOT}/ansible/hacking/env-setup
ANSIBLE=$(which ansible-playbook) ANSIBLE=$(which ansible-playbook)
fi fi
set -x -o nounset set -x -o nounset

View File

@ -3,6 +3,7 @@
VAGRANTFILE_API_VERSION = '2' VAGRANTFILE_API_VERSION = '2'
ansible_install_root=(ENV['ANSIBLE_INSTALL_ROOT'] || "/opt/stack")
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'ubuntu/trusty64' config.vm.box = 'ubuntu/trusty64'
@ -18,6 +19,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vb.customize ["modifyvm", :id, "--nictype3", "Am79C973"] vb.customize ["modifyvm", :id, "--nictype3", "Am79C973"]
end end
# If ANSIBLE_INSTALL_ROOT is available, set that value inside the VM
if ENV['ANSIBLE_INSTALL_ROOT']
bifrost.vm.provision "shell", inline: <<-SHELL
echo "export ANSIBLE_INSTALL_ROOT=#{ENV['ANSIBLE_INSTALL_ROOT']}" >> /etc/profile.d/ansible-root.sh
SHELL
end
# Set up private NAT'd network # Set up private NAT'd network
bifrost.vm.network 'private_network', ip: '192.168.99.10' # it goes to 11 bifrost.vm.network 'private_network', ip: '192.168.99.10' # it goes to 11
# This assumes you have DHCP on your bridged network. if not you will need # This assumes you have DHCP on your bridged network. if not you will need
@ -35,6 +43,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
ansible.playbook = 'vagrant.yml' ansible.playbook = 'vagrant.yml'
ansible.extra_vars = { ansible.extra_vars = {
# set key file name here # set key file name here
ansible_install_root: ansible_install_root,
public_key: 'id_rsa.pub', public_key: 'id_rsa.pub',
# Edit the network_interface to match your needs: # Edit the network_interface to match your needs:
# eth0 - connected to a Nat network # eth0 - connected to a Nat network

View File

@ -71,11 +71,16 @@
- name: Ensure /opt/stack folder exists - name: Ensure /opt/stack folder exists
file: path=/opt/stack state=directory owner=vagrant file: path=/opt/stack state=directory owner=vagrant
- name: Ensure ansible root folder exists
file: path={{ansible_install_root}} state=directory owner=vagrant
- name: Prepare VM for Bifrost - name: Prepare VM for Bifrost
command: /home/vagrant/bifrost/scripts/env-setup.sh command: /home/vagrant/bifrost/scripts/env-setup.sh
environment:
ANSIBLE_INSTALL_ROOT: "{{ansible_install_root}}"
- name: Install Bifrost - name: Install Bifrost
shell: source /opt/stack/ansible/hacking/env-setup && ansible-playbook -vvvv -i inventory/localhost install.yaml -e network_interface={{network_interface}} shell: source {{ansible_install_root}}/ansible/hacking/env-setup && ansible-playbook -vvvv -i inventory/localhost install.yaml -e network_interface={{network_interface}}
args: args:
chdir: /home/vagrant/bifrost/playbooks chdir: /home/vagrant/bifrost/playbooks
executable: /bin/bash executable: /bin/bash