From e6e0b2b9c5cad7f7a66b0aedaf3ab67438eedf2d Mon Sep 17 00:00:00 2001 From: varac Date: Mon, 7 Mar 2016 12:23:05 +0100 Subject: [vagrant] Vagrant now can deploy a pixelated box By default, a leap_platform-only box will get started. To start the pixelated box, use `vagrant up pixelated`. --- Vagrantfile | 70 ++++++++++++++++++++++++++++------------------- vagrant/add-pixelated.sh | 32 ++++++++++++++++++++++ vagrant/configure-leap.sh | 12 ++------ vagrant/vagrant.config | 10 ++++++- 4 files changed, 85 insertions(+), 39 deletions(-) create mode 100755 vagrant/add-pixelated.sh diff --git a/Vagrantfile b/Vagrantfile index 3654b69e..a4398b77 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,39 +1,53 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -Vagrant.configure("2") do |box| +Vagrant.configure("2") do |config| + + # shared config for all boxes + # Please verify the sha512 sum of the downloaded box before importing it into vagrant ! # see https://leap.se/en/docs/platform/details/development#Verify.vagrantbox.download # for details + config.vm.box = "LEAP/jessie" + + config.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + v.name = "jessie" + v.memory = 1536 + end + config.vm.provider "libvirt" do |v| + v.memory = 1536 + end + + # Fix annoying 'stdin: is not a tty' warning + # see http://foo-o-rama.com/vagrant--stdin-is-not-a-tty--fix.html + config.vm.provision "fix-no-tty", type: "shell" do |s| + s.privileged = false + s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile" + end + + config.vm.provision "puppet" do |puppet| + puppet.manifests_path = "./vagrant" + puppet.module_path = "./puppet/modules" + puppet.manifest_file = "install-platform.pp" + puppet.options = "--verbose" + puppet.hiera_config_path = "hiera.yaml" + end + config.vm.provision "shell", path: "vagrant/configure-leap.sh" + + config.ssh.username = "vagrant" + + # forward leap_web ports + config.vm.network "forwarded_port", guest: 443, host:4443 + # forward pixelated ports + config.vm.network "forwarded_port", guest: 8080, host:8080 + + config.vm.define :"leap_platform", primary: true do |leap_vagrant| + end - box.vm.define :"jessie", primary: true do |config| - - config.vm.box = "LEAP/jessie" - config.vm.provider "virtualbox" do |v| - v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - v.name = "jessie" - v.memory = 1536 - end - - config.vm.provider "libvirt" do |v| - v.memory = 1536 - end - - config.vm.provision "puppet" do |puppet| - puppet.manifests_path = "./vagrant" - puppet.module_path = "./puppet/modules" - puppet.manifest_file = "install-platform.pp" - puppet.options = "--verbose" - puppet.hiera_config_path = "hiera.yaml" - end - config.vm.provision "shell", path: "vagrant/configure-leap.sh" - config.ssh.username = "vagrant" - - # forward leap_web ports - config.vm.network "forwarded_port", guest: 443, host:4443 - # forward pixelated ports - config.vm.network "forwarded_port", guest: 8080, host:8080 + config.vm.define :"pixelated", autostart: false do |pixelated_vagrant| + pixelated_vagrant.vm.provision "shell", path: "vagrant/add-pixelated.sh" end end diff --git a/vagrant/add-pixelated.sh b/vagrant/add-pixelated.sh new file mode 100755 index 00000000..f9908947 --- /dev/null +++ b/vagrant/add-pixelated.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# adds pixelated-server to the node + +. /vagrant/vagrant/vagrant.config + +cd "$PROVIDERDIR" + +if ! git submodule status files/puppet/modules/pixelated > /dev/null 2>&1; then + git submodule add https://github.com/pixelated/puppet-pixelated.git files/puppet/modules/pixelated +fi + +echo '{}' > services/pixelated.json +[ -d files/puppet/modules/custom/manifests ] || mkdir -p files/puppet/modules/custom/manifests +echo 'class custom { include ::pixelated}' > files/puppet/modules/custom/manifests/init.pp + +$LEAP $OPTS -v 2 deploy + +echo '===============================================' +echo 'testing the platform' +echo '===============================================' + +$LEAP $OPTS -v 2 test --continue + + +echo -e '\n===========================================================================================================\n\n' +echo -e 'You are now ready to use your vagrant Pixelated provider.\n' + +echo -e 'The LEAP webapp is available at https://localhost:4443. Use it to register an account before using the Pixelated Useragent.\n' +echo -e 'The Pixelated Useragent is available at https://localhost:8080\n' + +echo -e 'Please add an exception for both sites in your browser dialog to allow the self-signed certificate.\n' diff --git a/vagrant/configure-leap.sh b/vagrant/configure-leap.sh index bf07f3a6..9ddee039 100755 --- a/vagrant/configure-leap.sh +++ b/vagrant/configure-leap.sh @@ -3,15 +3,6 @@ . /vagrant/vagrant/vagrant.config -#OPTS='--no-color' -OPTS='' -USER='vagrant' -NODE='node1' -SUDO="sudo -u ${USER}" -PROVIDERDIR="/home/${USER}/leap/configuration" -LEAP="$SUDO /usr/local/bin/leap" -GIT="$SUDO git" - echo '===============================================' echo 'configuring leap' echo '===============================================' @@ -93,8 +84,9 @@ echo -e '\n===================================================================== echo -e 'You are now ready to use your local LEAP provider.\n' echo 'If you want to use the *Bitmask client* with your provider, please update your /etc/hosts with following dns overrides:' -$LEAP leap list --print ip_address,domain.full,dns.aliases | sed 's/^.* //' | sed 's/, null//g' | tr -d '\]\[",' +$LEAP list --print ip_address,domain.full,dns.aliases | sed 's/^.* //' | sed 's/, null//g' | tr -d '\]\[",' echo 'Please see https://leap.se/en/docs/platform/tutorials/vagrant#use-the-bitmask-client-to-do-an-initial-soledad-sync for more details how to use and test your LEAP provider.' echo -e "\nIf you don't want to use the Bitmask client, please ignore the above instructions.\n" echo -e 'The LEAP webapp is now available at https://localhost:4443\n' +echo -e 'Please add an exception in your browser dialog to allow the self-signed certificate.\n' diff --git a/vagrant/vagrant.config b/vagrant/vagrant.config index 4d568c03..e601488d 100644 --- a/vagrant/vagrant.config +++ b/vagrant/vagrant.config @@ -1,4 +1,4 @@ -# config values used by configure-leap.sh +# provider config values used by vagrant provision scripts provider_domain='example.org' provider_name='Leap Example Provider' contacts="no-reply@$provider_domain" @@ -11,4 +11,12 @@ contacts="no-reply@$provider_domain" # services='webapp,mx,couchdb,soledad,monitor' services='webapp,mx,couchdb,soledad' +# default vars used by vagrant provision scripts +OPTS='' +USER='vagrant' +NODE='node1' +SUDO="sudo -u ${USER}" +PROVIDERDIR="/home/${USER}/leap/configuration" +LEAP="$SUDO /usr/local/bin/leap" +GIT="$SUDO git" -- cgit v1.2.3