Skip to content

Commit

Permalink
fix(vagrant): remove ansible and use bash. (Scifabric#2003)
Browse files Browse the repository at this point in the history
Use bash scripts to setup everything.
  • Loading branch information
teleyinex authored Nov 15, 2020
1 parent a770c0b commit 997f131
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 24 deletions.
27 changes: 3 additions & 24 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,15 @@

VAGRANTFILE_API_VERSION = "2"

# Ansible install script for Ubuntu
$ansible_install_script = <<SCRIPT
export DEBIAN_FRONTEND=noninteractive
echo Check if Ansible existing...
if ! which ansible >/dev/null; then
echo update package index files...
apt-get update -qq
echo install Ansible...
apt-get install -qq ansible
fi
SCRIPT

$ansible_local_provisioning_script = <<SCRIPT
export DEBIAN_FRONTEND=noninteractive
export PYTHONUNBUFFERED=1
echo PYBOSSA provisioning with Ansible...
ansible-playbook -u vagrant /vagrant/provisioning/playbook.yml -i /vagrant/provisioning/ansible_hosts -c local
SCRIPT

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.box = "bento/ubuntu-20.04"
config.vm.provider "virtualbox" do |v|
v.memory = 1024
end
config.vm.network :forwarded_port, host: 5000, guest: 5000
config.vm.network :forwarded_port, host: 5001, guest: 5001
# turn off warning message `stdin: is not a tty error`
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
# be sure that there is Ansible for local provisioning
config.vm.provision "shell", inline: $ansible_install_script
# do the final Ansible local provisioning
config.vm.provision "shell", inline: $ansible_local_provisioning_script
config.vm.provision "shell", path: "contrib/server.sh"
config.vm.provision "shell", path: "contrib/pybossa.sh", privileged: false
end
28 changes: 28 additions & 0 deletions contrib/pybossa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[ ! -d "/home/vagrant/.pyenv" ] && curl https://pyenv.run | bash

export PATH="/home/vagrant/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

tee -a ~/home/vagrant/.bashrc << END
export PATH="/home/vagrant/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
END

pyenv install 3.6.12
pyenv global 3.6.12
echo setting up PYBOSSA...
git clone --recursive https://github.com/Scifabric/pybossa
cd pybossa
python -mvenv env
source env/bin/activate
pip install -U pip
pip install -r requirements.txt
cp settings_local.py.tmpl settings_local.py
cp alembic.ini.template alembic.ini
redis-server contrib/sentinel.conf --sentinel
python cli.py db_create
python run.py
8 changes: 8 additions & 0 deletions contrib/server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
echo update package index files...
apt-get update -qq

echo installing required external libraries...
apt-get -y install git postgresql postgresql-server-dev-all libpq-dev python3-psycopg2 libsasl2-dev libldap2-dev libssl-dev python3-venv python-dev build-essential libjpeg-dev libssl-dev libffi-dev dbus libdbus-1-dev libdbus-glib-1-dev libldap2-dev libsasl2-dev redis-server python3-dev

sudo su postgres -c "psql -c \"CREATE ROLE pybossa SUPERUSER LOGIN PASSWORD 'tester'\" "
sudo su postgres -c "createdb pybossa -O pybossa"

0 comments on commit 997f131

Please sign in to comment.