diff --git a/README.md b/README.md index c9866f2ebedd590ddabf44d9cc4d5feaa39cc707..8a0b8fdc520df6a05f1b6324a9872a9515c5f8de 100644 --- a/README.md +++ b/README.md @@ -5,27 +5,61 @@ [Vagrant 1.9+](https://www.vagrantup.com/downloads.html) -#### Usage +#### Configure -`VERSION=x.x.x EDITION="ee|ce" vagrant up` -i.e. +Data file gitlab-vagrant.yml contains profiles for each of your vagrant machines. +Name can be any parseable format, such as: -`VERSION=9.1.1 EDITION="ee" vagrant up` +gitlab-edition-version +gitlab-ticket-number +gitlab-date +Example: -The application will be available on http://localhost:version}. If the port is 3 digits add another 0, i.e. Version 9.1.1 will accessible from https://localhost:9110 on the host. This is to avoid running on a privileged port. +``` +--- +- name: gitlab-ee-latest + version: 9.1.1 + edition: ee + host_port: 9110 + +- name: gitlab-ce-12345 + version: 8.17.3 + edition: ce + host_port: 8173 +``` + +Make changes to this file and save. + +For the following steps change name to the name of the machine in your profile, i.e. gitlab-ee-12345. + +#### Provision + +`vagrant up name` + +#### Status + +Show all running machines: + +`vagrant global-status` + +Show status of specific machine: + +`vagrant status name` #### Connect via SSH -If you need to SSH onto the guest VM then: -`VERSION=9.1.1 EDITION="ee" vagrant ssh` +`vagrant ssh name` #### Cleanup Once you are finished testing etc you can remove the VM with: -`VERSION=9.1.1 EDITION="ee" vagrant destroy` +`vagrant destroy name` + +#### Reprovision -and recreate new VMs as you please using the above steps. +To reprovision an existing machine: +`vagrant up name --provision` diff --git a/Vagrantfile b/Vagrantfile index 7fc5d79a527f56c8d4815e892c01bc43abde80c4..85be6acfe6d30c65d20353e3b59481eed42eebfd 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,27 +1,37 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -ver = ENV['VERSION'] -lic = ENV['EDITION'] -lic = lic.downcase +# Specify minimum Vagrant version and Vagrant API version +Vagrant.require_version ">= 1.6.0" +#VAGRANTFILE_API_VERSION = "2" + +# Require YAML module +require 'yaml' -get_package = "curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-#{lic}/script.deb.sh | sudo bash" -host_port = ver.gsub(/[\.]/,"") + "0" +gitlab_vagrant = YAML.load_file('gitlab-vagrant.yml') Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/xenial64" - config.vm.network "forwarded_port", guest: 80, host: host_port[0..4], - auto_correct: true + gitlab_vagrant.each do |gitlab_vagrant| - config.vm.provider "virtualbox" do |vb| - vb.memory = "4096" - end - - config.vm.provision "shell", inline: <<-SHELL - sudo DEBIAN_FRONTEND=noninteractive apt-get install curl openssh-server ca-certificates postfix - #{get_package} - sudo apt-get install gitlab-#{lic}=#{ver}-#{lic}.0 - sudo gitlab-ctl reconfigure - SHELL + name = gitlab_vagrant["name"] + version = gitlab_vagrant["version"] + edition = gitlab_vagrant["edition"] + host_port = gitlab_vagrant["host_port"] + config.vm.define name do |provision| + config.vm.box = "ubuntu/xenial64" + config.vm.network "forwarded_port", guest: 80, host: host_port, + auto_correct: true + config.vm.provider "virtualbox" do |vb| + vb.memory = "4096" + end + + config.vm.provision "shell", inline: <<-SHELL + sudo DEBIAN_FRONTEND=noninteractive apt-get install curl openssh-server ca-certificates postfix + curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-#{edition}/script.deb.sh | sudo bash + sudo apt-get install gitlab-#{edition}=#{version}-#{edition}.0 + sudo gitlab-ctl reconfigure + SHELL + end + end end diff --git a/gitlab-vagrant.yml b/gitlab-vagrant.yml new file mode 100644 index 0000000000000000000000000000000000000000..d0e16357ee9870a006e69c21af2352746783b652 --- /dev/null +++ b/gitlab-vagrant.yml @@ -0,0 +1,10 @@ +--- +- name: gitlab-ee-latest + version: 9.1.1 + edition: ee + host_port: 9110 + +- name: gitlab-ce-12345 + version: 8.17.3 + edition: ce + host_port: 8173