Skip to content

Commit

Permalink
Merge pull request #1458 from M0ses/vagrant_with_leap
Browse files Browse the repository at this point in the history
[dist] vagrant file and bootstrap to use Leap
  • Loading branch information
M0ses committed Jan 18, 2016
2 parents 9e7c90f + 3aac4c1 commit 701cfb2
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 230 deletions.
51 changes: 17 additions & 34 deletions Vagrantfile
Expand Up @@ -11,10 +11,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

# Every Vagrant virtual environment requires a box to build off of.
config.vm.define "frontend" , primary: true do |fe|
fe.vm.box = 'webhippie/opensuse-13.2'
fe.vm.box = 'M0ses/openSUSE-Leap-42.1-minimal'
# Provision the box with a simple shell script
fe.vm.provision :shell, path: 'bootstrap.sh'
fe.vm.provision :shell, inline: 'mount /vagrant/src/api/tmp', run: "always"
fe.vm.provision :shell, inline: '/vagrant/contrib/bootstrap_frontend.sh'

# Execute commands in the frontend directory
fe.exec.commands '*', directory: '/vagrant/src/api'
Expand All @@ -24,51 +23,42 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|


config.vm.define "appliance" , primary: true do |app|
app.vm.box = 'webhippie/opensuse-13.2'
app.vm.box = 'M0ses/openSUSE-Leap-42.1-minimal'

# Provision the box with a simple shell script
app.vm.provision :shell, path: 'bootstrap-appliance.sh'
app.vm.provision :shell, inline: '/vagrant/contrib/bootstrap_appliance.sh'

# reboot vm to run obsapisetup
app.vm.provision :reload

# finalize installation
app.vm.provision :shell, path: 'bootstrap-appliance-finalize.sh'
app.vm.provision :shell, inline: '/vagrant/contrib/bootstrap_appliance-finalize.sh'

end

config.vm.define "rpm-test" , primary: true do |rpmt|
rpmt.vm.box = 'webhippie/opensuse-13.2'
rpmt.vm.box = 'M0ses/openSUSE-Leap-42.1-minimal'
# Provision the box with a simple shell script
rpmt.vm.provision :shell, inline: <<SCRIPT
export NO_CAT_LOG=1
echo -e "\ninstalling required software packages...\n"
echo 'solver.allowVendorChange = true' >> /etc/zypp/zypp.conf
zypper -q ar -f http://download.opensuse.org/repositories/OBS:/Server:/Unstable/openSUSE_13.2/OBS:Server:Unstable.repo
zypper -q --gpg-auto-import-keys refresh
zypper -q -n install --no-recommends update-alternatives ruby-devel make gcc gcc-c++ patch cyrus-sasl-devel openldap2-devel libmysqld-devel libxml2-devel zlib-devel libxslt-devel nodejs mariadb memcached sphinx screen sphinx phantomjs obs-api-testsuite-deps inst-source-utils ruby2.2-rubygem-sqlite3
. /vagrant/contrib/common.sh
# The newer version creates false positives in test:api
zypper -q -n install --force createrepo-0.9.9-10.35.1
allow_vendor_change
echo -e "\nsetup ruby binaries...\n"
for bin in rake rdoc ri; do
/usr/sbin/update-alternatives --set $bin /usr/bin/$bin.ruby.ruby2.2
done
add_common_repos
echo -e "\ndisabling versioned gem binary names...\n"
echo 'install: --no-format-executable' >> /etc/gemrc
install_common_packages
gem install bundle
BUNDLE_GEMFILE=/vagrant/src/api/Gemfile bundle install
setup_ruby
install_bundle
make -C /vagrant
make -C /vagrant install
make -C /vagrant/src/api test
#chown -R vagrant /vagrant
chown -R vagrant /vagrant
SCRIPT

end
Expand Down Expand Up @@ -105,20 +95,13 @@ SCRIPT

# Use 1Gb of RAM for Vagrant box (otherwise bundle will go to swap)
config.vm.provider :virtualbox do |vb|

vb.customize ['modifyvm', :id, '--memory', '2048']
vb.destroy_unused_network_interfaces = true
config.vm.provision :shell, inline: <<SCRIPT
echo "Setting up your OBS test backend..."
# Put the backend data dir outside the shared folder so it can use hardlinks
# which isn't possible with VirtualBox shared folders...
mkdir /tmp/vagrant_tmp
mkdir /tmp/vagrant_log/
chown vagrant:users /tmp/vagrant_tmp
chown vagrant:users -R /tmp/vagrant_log/
echo -e "/tmp/vagrant_tmp /vagrant/src/api/tmp none bind 0 0" >> /etc/fstab
echo -e "/tmp/vagrant_log /vagrant/src/api/log none bind 0 0" >> /etc/fstab
mount -a

config.vm.provision :shell, inline: <<SCRIPT
. /vagrant/contrib/common.sh
setup_obs_backend
SCRIPT
end

Expand Down
127 changes: 0 additions & 127 deletions bootstrap-appliance.sh

This file was deleted.

69 changes: 0 additions & 69 deletions bootstrap.sh

This file was deleted.

File renamed without changes.
96 changes: 96 additions & 0 deletions contrib/bootstrap_appliance.sh
@@ -0,0 +1,96 @@
#!/bin/bash

MYSQL_USER=root
MYSQL_PASSWD=opensuse
OBS_DIST_ID="openSUSE_Leap_42.1"

BASEDIR=`dirname $0`
. $BASEDIR/common.sh


allow_vendor_change

for repo in \
http://download.opensuse.org/repositories/devel:/languages:/perl/$OBS_DIST_ID/devel:languages:perl.repo
do
zypper -q ar -f $repo
done

add_common_repos

install_common_packages


setup_ruby

install_bundle

[ -d /srv/www/obs/api/config/ ] || mkdir -p /srv/www/obs/api/config/
cp /vagrant/src/api/config/database.yml.example /srv/www/obs/api/config/database.yml
cp /vagrant/src/api/config/options.yml.example /srv/www/obs/api/config/options.yml

echo -e "\nChanging mysql password and settings\n"

systemctl start mysql.service
systemctl enable mysql.service

mysqladmin -u $MYSQL_USER password "$MYSQL_PASSWD"
cat <<EOF >/root/.my.cnf
[client]
password=$MYSQL_PASSWD
user=$MYSQL_USER
[mysqladmin]
password=$MYSQL_PASSWD
user=$MYSQL_USER
EOF

echo -e "\nInstalling backend components\n"
cp -a /vagrant/src/backend /usr/lib/obs/server

echo -e "\nEnabling backend services\n"
for srv in obsapidelayed obsapisetup obsdispatcher obspublisher obsrepserver obsscheduler obssrcserver;do
echo " - Working on $srv"
cp /vagrant/dist/$srv /etc/init.d
systemctl enable $srv\.service
done

echo -e "\nChecking required directories\n"
for dir in /srv/obs /srv/www/obs /srv/www/obs/overview/ /usr/lib/obs /srv/www/obs/api/log/ /srv/www/obs/api/tmp;do
echo " - Checking $dir"
[ -d $dir ] || mkdir -p $dir
done

setup_memcached

prepare_apache2

echo -e "\nInstalling api components\n"
cp -a /vagrant/src/api /srv/www/obs
cp -a /vagrant/dist/obs-apache24.conf /etc/apache2/vhosts.d/obs.conf
cp /vagrant/dist/overview.html.TEMPLATE /srv/www/obs/overview/
cd /srv/www/obs/api/
echo "" | sha256sum|awk '{print $1}' > config/secret.key
chown wwwrun:www -R /srv/www/obs/api/log/
chown wwwrun:www -R /srv/www/obs/api/tmp

echo -e "\nInstalling obsapisetup components\n"
make -C /vagrant/dist install

echo -e "\nConfiguring BS_API_AUTOSETUP\n"
perl -p -i -e 's#BS_API_AUTOSETUP=.*#BS_API_AUTOSETUP="yes"#' /etc/sysconfig/obs-server


cd /srv/www/obs/api

bundle exec rake assets:precompile RAILS_ENV=production RAILS_GROUPS=assets 2>/dev/null

touch /srv/www/obs/api/config/production.sphinx.conf
chown wwwrun:www /srv/www/obs/api/config/production.sphinx.conf

echo "fstab content"
cat /etc/fstab

exit 0

0 comments on commit 701cfb2

Please sign in to comment.