Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Revert "Redo Vagrant for Puppet testing, assuming targeting AWS"
Browse files Browse the repository at this point in the history
This reverts commit e965707.
  • Loading branch information
rtrinque committed Jul 20, 2018
1 parent a8c2d30 commit 118be36
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 449 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ REVISION
.vagrant
/development-vm/Vagrantfile.localconfig
/gpg/random_seed
vagrant.nodes.local.yaml
nodes.local.yaml
gpg_recipients/.*last_updated
80 changes: 36 additions & 44 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'yaml'
require_relative 'load_nodes'

min_required_vagrant_version = '1.3.0'

# Construct box name and URL from distro and version.
def get_box(dist, version)
dist ||= "trusty"
version ||= '20160323'

name = "govuk_dev_#{dist}64_#{version}"
bucket = 'govuk-dev-boxes-test'
url = "https://#{bucket}.s3.amazonaws.com/#{name}.box"

return name, url
end

if Vagrant::VERSION < min_required_vagrant_version
$stderr.puts "ERROR: Puppet now requires Vagrant version >=#{min_required_vagrant_version}. Please upgrade.\n"
exit 1
end

nodes = load_nodes()
Vagrant.configure("2") do |config|
# Enable vagrant-cachier if available.
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.auto_detect = true
end

config.ssh.shell = 'bash'

node_manifest = YAML::load_file(File.expand_path("./vagrant.nodes.yaml", File.dirname(__FILE__)))

if File.exists?(File.expand_path("./vagrant.nodes.local.yaml", File.dirname(__FILE__))) then
local_overrides = YAML::load_file(File.expand_path("./vagrant.nodes.local.yaml", File.dirname(__FILE__)))
node_manifest.merge!(local_overrides)
end

defaults = node_manifest['defaults']

node_names = node_manifest['nodes'].keys.sort
node_names.each_index do |node_i|
node_name = node_names[node_i]
if node_manifest['nodes'][node_name].nil? then
node_attributes = defaults
else
node_attributes = defaults.merge(node_manifest['nodes'][node_name])
end

nodes.each do |node_name, node_opts|
config.vm.define node_name do |c|
c.vm.box = node_attributes['box']

if node_attributes['box_url']
c.vm.box_url = node_attributes['box_url']
end

box_name, box_url = get_box(
node_opts["box_dist"],
node_opts["box_version"],
)
c.vm.box = box_name
c.vm.box_url = box_url
c.vm.hostname = "#{node_name}.dev.gov.uk"
c.vm.network :private_network, {
:ip => "10.1.0.#{node_i + 10}",
:netmask => "255.255.255.0"
:ip => node_opts["ip"],
:netmask => "255.000.000.000"
}

modifyvm_args = ['modifyvm', :id]
Expand All @@ -50,8 +54,8 @@ Vagrant.configure("2") do |config|
modifyvm_args << "--natdnsproxy1" << "on"
modifyvm_args << "--natdnshostresolver1" << "on"

if node_attributes.has_key?("memory")
modifyvm_args << "--memory" << node_attributes["memory"]
if node_opts.has_key?("memory")
modifyvm_args << "--memory" << node_opts["memory"]
end

c.vm.provider(:virtualbox) { |vb| vb.customize(modifyvm_args) }
Expand All @@ -69,22 +73,10 @@ Vagrant.configure("2") do |config|
c.vm.synced_folder ".", "/usr/share/puppet/production/current"
end

node_puppet_role = node_name.split('.')[0].gsub(/[\-0-9]+$/, '')

c.vm.provision :shell, :path => 'tools/vagrant-bootstrap'
# run a script to partition extra disks for lvm if they exist.
c.vm.provision :shell, :inline => "/var/govuk/govuk-puppet/tools/partition-disks"
c.vm.provision :shell, :inline => '/var/govuk/govuk-puppet/tools/mock-ec2-metadata-service.py'
c.vm.provision :shell, :inline => 'mkdir -p /etc/facter/facts.d'
c.vm.provision :shell, :inline => "echo 'aws_migration=#{node_puppet_role}' > /etc/facter/facts.d/aws_migration.txt"
c.vm.provision :shell, :inline => "echo 'aws_stackname=blue' > /etc/facter/facts.d/aws_stackname.txt"

c.vm.provision :shell,
inline: '/var/govuk/govuk-puppet/tools/puppet3-bootstrap',
env: { 'INSTALL_GEMS' => '1' }

c.vm.provision :shell,
path: 'tools/puppet-apply',
args: ENV['VAGRANT_GOVUK_PUPPET_OPTIONS'],
env: { 'ENVIRONMENT' => 'vagrant' }
c.vm.provision :shell, :inline => "ENVIRONMENT=vagrant /var/govuk/govuk-puppet/tools/puppet-apply #{ENV['VAGRANT_GOVUK_PUPPET_OPTIONS']}"
end
end
end
39 changes: 0 additions & 39 deletions hieradata_aws/vagrant.yaml

This file was deleted.

Loading

0 comments on commit 118be36

Please sign in to comment.