Skip to content
Permalink
Browse files

[Vagrant] install debops from PyPI if /vagrant not mounted

  • Loading branch information...
nqb committed Oct 1, 2019
1 parent 6f956f2 commit 6453412f6ff5d6f88ca28b76580ad984f1e93764
Showing with 45 additions and 19 deletions.
  1. +45 −19 Vagrantfile
@@ -21,9 +21,12 @@
# VAGRANT_NODE_BOX="debian/buster64"
# Specify the box to use for nodes.
#
# ANSIBLE_FROM="debian" / ANSIBLE_FROM="pypi" / ANSIBLE_FROM="devel"
# ANSIBLE_FROM="debian" (default) / ANSIBLE_FROM="pypi" / ANSIBLE_FROM="devel"
# Specify the way to install ansible.
#
# DEBOPS_FROM="devel" / DEBOPS_FROM="pypi"
# Specify the way to install debops.
#
# VAGRANT_HOSTNAME="buster"
# Set a custom hostname after the box boots up.
#
@@ -184,6 +187,7 @@ readonly PROVISION_APT_HTTP_PROXY="#{ENV['APT_HTTP_PROXY']}"
readonly PROVISION_APT_HTTPS_PROXY="#{ENV['APT_HTTPS_PROXY']}"
readonly PROVISION_APT_FORCE_NETWORK="#{ENV['APT_FORCE_NETWORK']}"
readonly PROVISION_ANSIBLE_FROM="#{ENV['ANSIBLE_FROM'] || 'debian'}"
readonly PROVISION_DEBOPS_FROM="#{ENV['DEBOPS_FROM'] || 'devel'}"
readonly VAGRANT_PREPARE_BOX="#{ENV['VAGRANT_PREPARE_BOX']}"
# Install the Jane script
@@ -329,6 +333,14 @@ else
ansible_from_devel="${PROVISION_ANSIBLE_FROM}"
fi
debops_from_pypi=""
debops_from_devel=""
if [ "${PROVISION_DEBOPS_FROM}" == "pypi" ] || ! [ -d "/vagrant" ] ; then
debops_from_pypi="debops"
else
debops_from_devel="true"
fi
# Configure Ansible
if ! type ansible > /dev/null 2>&1 ; then
jane notify warning "Ansible not found"
@@ -463,15 +475,17 @@ if [ -z "${JANE_BOX_INIT:-}" ] ; then
# vagrant-libvirt executes virt-sysprep during box packaging.
# virt-sysprep zeroes out files in /usr/local/*, apparently.
# So we need to install PyPI packages on the real box, not the template.
jane notify install "Installing test requirements via PyPI..."
pip3 install netaddr python-ldap dnspython passlib future testinfra ${ansible_from_pypi}
mkdir /tmp/build
rsync -a --exclude '.vagrant' /vagrant/ /tmp/build
cd /tmp/build
make sdist > /dev/null
pip3 install dist/*
cd - > /dev/null
jane notify install "Installing requirements via PyPI..."
pip3 install netaddr python-ldap dnspython passlib future testinfra ${ansible_from_pypi} ${debops_from_pypi}
if [ -n "${debops_from_devel}" ] ; then
mkdir /tmp/build
rsync -a --exclude '.vagrant' /vagrant/ /tmp/build
cd /tmp/build
make sdist > /dev/null
pip3 install dist/*
cd - > /dev/null
fi
jane notify cache "Cleaning up cache directories..."
rm -rf /root/.cache/* /tmp/*
@@ -557,6 +571,7 @@ $provision_controller = <<SCRIPT
set -o nounset -o pipefail -o errexit
readonly PROVISION_ANSIBLE_FROM="#{ENV['ANSIBLE_FROM'] || 'debian'}"
readonly PROVISION_DEBOPS_FROM="#{ENV['DEBOPS_FROM'] || 'devel'}"
jane notify info "Configuring Ansible Controller host..."
@@ -569,22 +584,33 @@ if [ "${PROVISION_ANSIBLE_FROM}" == "pypi" ] ; then
ansible_from_pypi="ansible"
fi
jane notify install "Installing test requirements via PyPI..."
debops_from_pypi=""
debops_from_devel=""
if [ "${PROVISION_DEBOPS_FROM}" == "pypi" ] || ! [ -d "/vagrant" ] ; then
debops_from_pypi="debops"
else
debops_from_devel="true"
fi
jane notify install "Installing requirements via PyPI..."
sudo pip3 install netaddr python-ldap dnspython passlib future testinfra ${ansible_from_pypi}
mkdir /tmp/build
rsync -a --exclude '.vagrant' /vagrant/ /tmp/build
cd /tmp/build
make sdist > /dev/null
sudo pip3 install dist/*
cd - > /dev/null
sudo pip3 install netaddr python-ldap dnspython passlib future testinfra ${ansible_from_pypi} ${debops_from_pypi}
if [ -n "${debops_from_devel}" ] ; then
mkdir /tmp/build
rsync -a --exclude '.vagrant' /vagrant/ /tmp/build
cd /tmp/build
make sdist > /dev/null
sudo pip3 install dist/*
cd - > /dev/null
fi
jane notify cache "Cleaning up cache directories..."
sudo rm -rf /root/.cache/* /tmp/*
if ! [ -e .local/share/debops/debops ] ; then
mkdir -p src .local/share/debops
if [ -d "/vagrant" ] ; then
if [ -n "${debops_from_devel}" ] ; then
jane notify info "Symlinking '/vagrant' to '~vagrant/.local/share/debops/debops'"
ln -s /vagrant .local/share/debops/debops
else

0 comments on commit 6453412

Please sign in to comment.
You can’t perform that action at this time.