From 2d2dd3c091af05dc9d1f1744c73b2f3da9146c9d Mon Sep 17 00:00:00 2001 From: Adam Mulvany <amulvany@gitlab.com> Date: Tue, 2 May 2017 13:25:17 +0700 Subject: [PATCH] Added yaml support with profiles --- README.md | 52 ++++++++++++++++++++++++++++++++++++++-------- Vagrantfile | 46 ++++++++++++++++++++++++---------------- gitlab-vagrant.yml | 10 +++++++++ 3 files changed, 81 insertions(+), 27 deletions(-) create mode 100644 gitlab-vagrant.yml diff --git a/README.md b/README.md index c9866f2..8a0b8fd 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 7fc5d79..85be6ac 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 0000000..d0e1635 --- /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 -- GitLab