Make ansible installation directory configurable
This change helps with the remote problem where ansible is installed on a machine using the same script by User A and User B is also trying to use ansible using the same method. The change lets each user have his own copy of ansible installed in a directory of his/her choosing. Change-Id: I8fddaaa8cad291da840ac44c4b1e9a7a93f92aee Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com> Partial-Bug: #1589672
This commit is contained in:
parent
f89fae0c19
commit
e7fc06aadc
13
README.rst
13
README.rst
@ -122,10 +122,21 @@ If you are running the installation behind a proxy, export the
|
||||
environment variables ``http_proxy`` and ``https_proxy`` so that
|
||||
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::
|
||||
|
||||
bash ./scripts/env-setup.sh
|
||||
source /opt/stack/ansible/hacking/env-setup
|
||||
source ${ANSIBLE_INSTALL_ROOT}/stack/ansible/hacking/env-setup
|
||||
cd playbooks
|
||||
|
||||
The second part is an Ansible playbook that installs and configures ironic
|
||||
|
@ -46,3 +46,19 @@ Edit the Vagrantfile:
|
||||
Boot the VM with::
|
||||
|
||||
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``.
|
||||
|
@ -6,6 +6,7 @@ ANSIBLE_GIT_URL=${ANSIBLE_GIT_URL:-https://github.com/ansible/ansible.git}
|
||||
# issues with the stable branch.
|
||||
# https://github.com/ansible/ansible-modules-core/issues/2804
|
||||
ANSIBLE_GIT_BRANCH=${ANSIBLE_GIT_BRANCH:-v2.0.0.0-1}
|
||||
ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack}
|
||||
|
||||
function check_get_module () {
|
||||
local file=${1}
|
||||
@ -117,11 +118,11 @@ sudo -H -E ${PIP} install -r "$(dirname $0)/../requirements.txt"
|
||||
u=$(whoami)
|
||||
g=$(groups | awk '{print $1}')
|
||||
|
||||
if [ ! -d /opt/stack ]; then
|
||||
mkdir -p /opt/stack || (sudo mkdir -p /opt/stack)
|
||||
if [ ! -d ${ANSIBLE_INSTALL_ROOT} ]; then
|
||||
mkdir -p ${ANSIBLE_INSTALL_ROOT} || (sudo mkdir -p ${ANSIBLE_INSTALL_ROOT})
|
||||
fi
|
||||
sudo -H chown -R $u:$g /opt/stack
|
||||
cd /opt/stack
|
||||
sudo -H chown -R $u:$g ${ANSIBLE_INSTALL_ROOT}
|
||||
cd ${ANSIBLE_INSTALL_ROOT}
|
||||
|
||||
if [ ! -d ansible ]; then
|
||||
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
|
||||
|
||||
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 "To use bifrost, do"
|
||||
|
||||
@ -166,6 +167,6 @@ else
|
||||
echo "following commands to update your shell."
|
||||
echo
|
||||
echo "source env-vars"
|
||||
echo "source /opt/stack/ansible/hacking/env-setup"
|
||||
echo "source ${ANSIBLE_INSTALL_ROOT}/ansible/hacking/env-setup"
|
||||
echo
|
||||
fi
|
||||
|
@ -5,6 +5,7 @@ set -o pipefail
|
||||
export PYTHONUNBUFFERED=1
|
||||
SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)"
|
||||
BIFROST_HOME=$SCRIPT_HOME/..
|
||||
ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack}
|
||||
ENABLE_VENV="false"
|
||||
USE_DHCP="false"
|
||||
USE_VENV="false"
|
||||
@ -59,7 +60,7 @@ if [ ${USE_VENV} = "true" ]; then
|
||||
ENABLE_VENV="true"
|
||||
else
|
||||
$SCRIPT_HOME/env-setup.sh
|
||||
source /opt/stack/ansible/hacking/env-setup
|
||||
source ${ANSIBLE_INSTALL_ROOT}/ansible/hacking/env-setup
|
||||
ANSIBLE=$(which ansible-playbook)
|
||||
fi
|
||||
set -x -o nounset
|
||||
|
9
tools/vagrant_dev_env/Vagrantfile
vendored
9
tools/vagrant_dev_env/Vagrantfile
vendored
@ -3,6 +3,7 @@
|
||||
|
||||
VAGRANTFILE_API_VERSION = '2'
|
||||
|
||||
ansible_install_root=(ENV['ANSIBLE_INSTALL_ROOT'] || "/opt/stack")
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
|
||||
config.vm.box = 'ubuntu/trusty64'
|
||||
@ -18,6 +19,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
vb.customize ["modifyvm", :id, "--nictype3", "Am79C973"]
|
||||
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
|
||||
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
|
||||
@ -35,6 +43,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
ansible.playbook = 'vagrant.yml'
|
||||
ansible.extra_vars = {
|
||||
# set key file name here
|
||||
ansible_install_root: ansible_install_root,
|
||||
public_key: 'id_rsa.pub',
|
||||
# Edit the network_interface to match your needs:
|
||||
# eth0 - connected to a Nat network
|
||||
|
@ -71,11 +71,16 @@
|
||||
- name: Ensure /opt/stack folder exists
|
||||
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
|
||||
command: /home/vagrant/bifrost/scripts/env-setup.sh
|
||||
environment:
|
||||
ANSIBLE_INSTALL_ROOT: "{{ansible_install_root}}"
|
||||
|
||||
- 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:
|
||||
chdir: /home/vagrant/bifrost/playbooks
|
||||
executable: /bin/bash
|
||||
|
Loading…
x
Reference in New Issue
Block a user