bosh-bootstrap 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. data/.gitignore +0 -1
  2. data/.travis.yml +24 -3
  3. data/ChangeLog.md +8 -0
  4. data/Gemfile +5 -3
  5. data/Guardfile +3 -3
  6. data/Rakefile +21 -5
  7. data/lib/bosh/providers/aws.rb +67 -27
  8. data/lib/bosh/providers/base_provider.rb +27 -0
  9. data/lib/bosh/providers/openstack.rb +16 -6
  10. data/lib/bosh-bootstrap/cli.rb +166 -61
  11. data/lib/bosh-bootstrap/commander/remote_script_command.rb +7 -4
  12. data/lib/bosh-bootstrap/commander/remote_server.rb +12 -10
  13. data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/bosh_micro_deploy +5 -1
  14. data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/download_micro_bosh_stemcell +12 -6
  15. data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy.rb +4 -1
  16. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/configure_git +4 -9
  17. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/create_vcap_user +1 -1
  18. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_base_packages +12 -2
  19. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_bosh +3 -45
  20. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_bosh_by_gem_install +54 -0
  21. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_hub +26 -0
  22. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_ruby +10 -15
  23. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_useful_gems +1 -1
  24. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/validate_bosh_deployer +0 -5
  25. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm.rb +21 -15
  26. data/lib/bosh-bootstrap/stages/{stage_prepare_inception_vm → stage_salted_password}/convert_salted_password +0 -0
  27. data/lib/bosh-bootstrap/stages/stage_salted_password.rb +51 -0
  28. data/lib/bosh-bootstrap/stages/stage_setup_new_bosh.rb +0 -1
  29. data/lib/bosh-bootstrap/stages/stage_validate_inception_vm.rb +1 -1
  30. data/lib/bosh-bootstrap/stages.rb +1 -0
  31. data/lib/bosh-bootstrap/version.rb +1 -1
  32. data/spec/{functional → integration}/.gitkeep +0 -0
  33. data/spec/integration/aws/aws_basic_spec.rb +39 -0
  34. data/spec/integration/aws/aws_edge_prebuilt_ami_spec.rb +46 -0
  35. data/spec/integration/aws/aws_edge_prebuilt_spec.rb +46 -0
  36. data/spec/integration/aws/aws_edge_spec.rb +45 -0
  37. data/spec/integration/aws/aws_helpers.rb +79 -0
  38. data/spec/spec_helper.rb +6 -0
  39. data/spec/unit/aws_spec.rb +28 -6
  40. data/spec/unit/bosh/providers/aws_spec.rb +14 -0
  41. data/spec/unit/cli_spec.rb +10 -8
  42. data/vendor/cache/POpen4-0.1.4.gem +0 -0
  43. data/vendor/cache/Platform-0.4.0.gem +0 -0
  44. data/vendor/cache/activesupport-3.2.8.gem +0 -0
  45. data/vendor/cache/awesome_print-1.1.0.gem +0 -0
  46. data/vendor/cache/aws-s3-0.6.3.gem +0 -0
  47. data/vendor/cache/blobstore_client-0.4.0.gem +0 -0
  48. data/vendor/cache/bosh_cli-1.0.3.gem +0 -0
  49. data/vendor/cache/bosh_common-0.5.4.gem +0 -0
  50. data/vendor/cache/builder-3.1.4.gem +0 -0
  51. data/vendor/cache/coderay-1.0.8.gem +0 -0
  52. data/vendor/cache/diff-lcs-1.1.3.gem +0 -0
  53. data/vendor/cache/escape-0.0.4.gem +0 -0
  54. data/vendor/cache/excon-0.17.0.gem +0 -0
  55. data/vendor/cache/fog-1.8.0.gem +0 -0
  56. data/vendor/cache/formatador-0.2.4.gem +0 -0
  57. data/vendor/cache/guard-1.6.2.gem +0 -0
  58. data/vendor/cache/guard-rspec-2.4.0.gem +0 -0
  59. data/vendor/cache/highline-1.6.15.gem +0 -0
  60. data/vendor/cache/httpclient-2.2.4.gem +0 -0
  61. data/vendor/cache/i18n-0.6.1.gem +0 -0
  62. data/vendor/cache/json_pure-1.6.8.gem +0 -0
  63. data/vendor/cache/listen-0.7.2.gem +0 -0
  64. data/vendor/cache/log4r-1.1.10.gem +0 -0
  65. data/vendor/cache/lumberjack-1.0.2.gem +0 -0
  66. data/vendor/cache/method_source-0.8.1.gem +0 -0
  67. data/vendor/cache/mime-types-1.21.gem +0 -0
  68. data/vendor/cache/multi_json-1.1.0.gem +0 -0
  69. data/vendor/cache/net-scp-1.0.4.gem +0 -0
  70. data/vendor/cache/net-ssh-2.2.2.gem +0 -0
  71. data/vendor/cache/net-ssh-gateway-1.1.0.gem +0 -0
  72. data/vendor/cache/netaddr-1.5.0.gem +0 -0
  73. data/vendor/cache/nokogiri-1.5.6-java.gem +0 -0
  74. data/vendor/cache/nokogiri-1.5.6.gem +0 -0
  75. data/vendor/cache/open4-1.3.0.gem +0 -0
  76. data/vendor/cache/progressbar-0.9.2.gem +0 -0
  77. data/vendor/cache/pry-0.9.11.4-java.gem +0 -0
  78. data/vendor/cache/pry-0.9.11.4.gem +0 -0
  79. data/vendor/cache/rake-10.0.3.gem +0 -0
  80. data/vendor/cache/rb-fsevent-0.9.3.gem +0 -0
  81. data/vendor/cache/redcard-1.0.0.gem +0 -0
  82. data/vendor/cache/rspec-2.12.0.gem +0 -0
  83. data/vendor/cache/rspec-core-2.12.2.gem +0 -0
  84. data/vendor/cache/rspec-expectations-2.12.1.gem +0 -0
  85. data/vendor/cache/rspec-mocks-2.12.2.gem +0 -0
  86. data/vendor/cache/ruby-atmos-pure-1.0.5.gem +0 -0
  87. data/vendor/cache/ruby-hmac-0.4.0.gem +0 -0
  88. data/vendor/cache/settingslogic-2.0.9.gem +0 -0
  89. data/vendor/cache/slop-3.4.3.gem +0 -0
  90. data/vendor/cache/spoon-0.0.1.gem +0 -0
  91. data/vendor/cache/terminal-table-1.4.5.gem +0 -0
  92. data/vendor/cache/thor-0.17.0.gem +0 -0
  93. data/vendor/cache/uuidtools-2.1.3.gem +0 -0
  94. data/vendor/cache/xml-simple-1.1.2.gem +0 -0
  95. metadata +72 -7
  96. data/lib/bosh-bootstrap/stages/stage_setup_new_bosh/cleanup_permissions +0 -14
@@ -3,51 +3,9 @@
3
3
  # Install BOSH CLI
4
4
  #
5
5
  # Options:
6
- # * $UPGRADE - re-install or upgrade gems if already installed
7
- # * $INSTALL_BOSH_FROM_SOURCE - install from bosh git repo
6
+ # * $BOSH_RUBYGEM_SOURCE - URL for where bosh rubygems can be downloaded
8
7
 
9
8
  set -e # exit immediately if a simple command exits with a non-zero status
10
9
 
11
- if [[ $EUID -ne 0 ]]; then
12
- echo "ERROR: This script must be run as root" 1>&2
13
- exit 1
14
- fi
15
-
16
- # Install a gem if $UPGRADE exists or if gem not already installed
17
- function install_gem() {
18
- gem_name=$1
19
- options=$2
20
- if [[ ("${UPGRADE}X" != "X") || "$(gem list $gem_name | grep $gem_name)X" == "X" ]]; then
21
- gem install $gem_name $options --no-ri --no-rdoc
22
- else
23
- echo gem $gem_name already installed
24
- fi
25
- }
26
-
27
- install_gem net-ssh '-v 2.2.2'
28
- install_gem net-scp '-v 1.0.4'
29
- install_gem fog '-v 1.9.0'
30
-
31
- if [[ "${INSTALL_BOSH_FROM_SOURCE}X" != "X" ]]; then
32
- mkdir -p /var/vcap/store/repos
33
- cd /var/vcap/store/repos
34
- if [[ -d bosh ]]; then
35
- cd bosh
36
- git pull origin master
37
- else
38
- git clone https://github.com/cloudfoundry/bosh.git
39
- fi
40
-
41
- cd /var/vcap/store/repos/bosh
42
- bundle --deployment
43
- bundle --binstubs=/usr/local/sbin
44
-
45
- else
46
- install_gem bosh_deployer
47
- fi
48
-
49
- if [[ ! -d /var/tmp/bosh ]]; then
50
- echo "Symlinking the expected stemcell creation folder into mounted volume..."
51
- mkdir -p /var/vcap/store/tmp/bosh
52
- ln -s /var/vcap/store/tmp/bosh /var/tmp/bosh
53
- fi
10
+ cd /var/vcap/store/inception
11
+ bundle install
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Install BOSH CLI
4
+ #
5
+ # Options:
6
+ # * $UPGRADE - re-install or upgrade gems if already installed
7
+ # * $INSTALL_BOSH_FROM_SOURCE - install from bosh git repo
8
+ # * $BOSH_RUBYGEM_SOURCE - URL for where bosh rubygems can be downloaded
9
+
10
+ set -e # exit immediately if a simple command exits with a non-zero status
11
+
12
+ if [[ $EUID -ne 0 ]]; then
13
+ echo "ERROR: This script must be run as root" 1>&2
14
+ exit 1
15
+ fi
16
+
17
+ # Install a gem if $UPGRADE exists or if gem not already installed
18
+ function install_gem() {
19
+ gem_name=$1
20
+ options=$2
21
+ if [[ ("${UPGRADE}X" != "X") || "$(gem list $gem_name | grep $gem_name)X" == "X" ]]; then
22
+ gem install $gem_name $options --no-ri --no-rdoc
23
+ else
24
+ echo gem $gem_name already installed
25
+ fi
26
+ }
27
+
28
+ install_gem net-ssh '-v 2.2.2'
29
+ install_gem net-scp '-v 1.0.4'
30
+ install_gem fog '-v 1.9.0'
31
+
32
+ if [[ "${INSTALL_BOSH_FROM_SOURCE}X" != "X" ]]; then
33
+ mkdir -p /var/vcap/store/repos
34
+ cd /var/vcap/store/repos
35
+ if [[ -d bosh ]]; then
36
+ cd bosh
37
+ git pull origin master
38
+ else
39
+ git clone https://github.com/cloudfoundry/bosh.git
40
+ fi
41
+
42
+ cd /var/vcap/store/repos/bosh
43
+ bundle --deployment
44
+ bundle --binstubs=/usr/local/sbin
45
+
46
+ else
47
+ install_gem bosh_deployer
48
+ fi
49
+
50
+ if [[ ! -d /var/tmp/bosh ]]; then
51
+ echo "Symlinking the expected stemcell creation folder into mounted volume..."
52
+ mkdir -p /var/vcap/store/tmp/bosh
53
+ ln -s /var/vcap/store/tmp/bosh /var/tmp/bosh
54
+ fi
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+
3
+ if [[ $EUID -ne 0 ]]; then
4
+ echo "ERROR: This script must be run as root" 1>&2
5
+ exit 1
6
+ fi
7
+
8
+ set -e # exit immediately if a simple command exits with a non-zero status
9
+
10
+ cd /var/vcap/store/repos
11
+ if [[ ! -d hub ]]; then
12
+ git clone git://github.com/defunkt/hub.git
13
+ cd hub
14
+ else
15
+ cd hub
16
+ git pull origin master
17
+ fi
18
+ rake install prefix=/usr/local
19
+ chown -R vcap:vcap /var/vcap/store/repos/hub
20
+
21
+ if [[ $(grep "hub alias -s" /home/vcap/.bashrc) == "" ]]; then
22
+ echo 'adding hub alias to .bashrc'
23
+ echo 'eval "$(hub alias -s)"' >> /home/vcap/.bashrc
24
+ fi
25
+
26
+
@@ -13,23 +13,18 @@ if [[ $EUID -ne 0 ]]; then
13
13
  exit 1
14
14
  fi
15
15
 
16
- DISTRIB_CODENAME=lucid
16
+ RUBY_VERSION=ruby-1.9.3
17
17
 
18
18
  if [[ "$(which ruby)" == "" || "${UPGRADE}X" != "X" || ! ("$(ruby -v)" =~ "ruby 1.9.3") ]]; then
19
- echo "Adding the Unboxed APT repository..."
20
- echo "deb http://apt.unboxedconsulting.com/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/unboxed.list
21
-
22
- echo -e "\n Retrieving the PGP keys for the repository..."
23
- wget -O - http://apt.unboxedconsulting.com/release.asc | apt-key add -
24
-
25
- echo "Resynchronizing the package index files from their sources..."
26
- apt-get update
19
+ curl -L https://get.rvm.io | bash -s head --autolibs=3 --ruby=$RUBY_VERSION
20
+ source /etc/profile.d/rvm.sh
21
+ else
22
+ echo $RUBY_VERSION already installed
23
+ fi
27
24
 
28
- echo -e "Installing Ruby 1.9.3...\n"
29
- apt-get -y install ubxd-ruby1.9.3
25
+ sudo usermod -a -G rvm vcap
30
26
 
31
- echo -e "Upgrading to latest Rubygems..."
32
- gem update --system
33
- else
34
- echo Ruby 1.9.3 already installed
27
+ if [[ $(grep 'rvm $RUBY_VERSION --default' ~vcap/.profile) == "" ]]; then
28
+ echo "setting rvm default for ~vcap user"
29
+ echo "rvm $RUBY_VERSION --default" >> ~vcap/.profile
35
30
  fi
@@ -17,7 +17,7 @@ function install_gem() {
17
17
  gem_name=$1
18
18
  options=$2
19
19
  if [[ ("${UPGRADE}X" != "X") || "$(gem list $gem_name | grep $gem_name)X" == "X" ]]; then
20
- gem install $gem_name $options --no-ri --no-rdoc
20
+ gem install $gem_name $options --no-ri --no-rdoc -f
21
21
  else
22
22
  echo gem $gem_name already installed
23
23
  fi
@@ -4,11 +4,6 @@
4
4
 
5
5
  set -e # exit immediately if a simple command exits with a non-zero status
6
6
 
7
- if [[ $EUID -ne 0 ]]; then
8
- echo "ERROR: This script must be run as root" 1>&2
9
- exit 1
10
- fi
11
-
12
7
  echo "Testing for 'bosh micro deploy' command..."
13
8
 
14
9
  bosh_output=$(bosh --no-color help micro)
@@ -11,25 +11,20 @@ module Bosh::Bootstrap::Stages
11
11
  # using inception VM username login, create a vcap user with same authorizations
12
12
  server.create "vcap user", script("create_vcap_user",
13
13
  "ORIGUSER" => settings.inception.username),
14
- :user => settings.inception.username
14
+ ssh_username: settings.inception.username, run_as_root: true
15
15
  # install base Ubuntu packages used for bosh micro deployer
16
- server.install "base packages", script("install_base_packages")
16
+ server.install "base packages", script("install_base_packages"), run_as_root: true
17
17
  server.configure "git", script("configure_git",
18
18
  "GIT_USER_NAME" => settings["git"]["name"],
19
19
  "GIT_USER_EMAIL" => settings["git"]["email"])
20
- server.install "ruby 1.9.3", script("install_ruby", "UPGRADE" => settings[:upgrade_deps])
21
- server.install "useful ruby gems", script("install_useful_gems", "UPGRADE" => settings[:upgrade_deps])
22
- server.install "bosh", script("install_bosh",
23
- "UPGRADE" => settings[:upgrade_deps],
24
- "INSTALL_BOSH_FROM_SOURCE" => settings["bosh_git_source"] || "")
25
- server.install "bosh plugins", script("install_bosh_plugins", "UPGRADE" => settings[:upgrade_deps])
26
-
27
- # use inception VM to generate a salted password (local machine may not have mkpasswd)
28
- unless settings["bosh"]["salted_password"]
29
- server.capture_value "salted password", script("convert_salted_password", "PASSWORD" => settings.bosh.password),
30
- :settings => settings, :save_output_to_settings_key => "bosh.salted_password"
31
- end
32
-
20
+ server.install "ruby 1.9.3", script("install_ruby", "UPGRADE" => settings[:upgrade_deps]),
21
+ run_as_root: true
22
+ server.install "useful ruby gems", script("install_useful_gems", "UPGRADE" => settings[:upgrade_deps]),
23
+ run_as_root: true
24
+ server.install "hub", script("install_hub"),
25
+ run_as_root: true
26
+ server.upload_file "/var/vcap/store/inception/Gemfile", gemfile
27
+ server.install "bosh", script("install_bosh")
33
28
  server.validate "bosh deployer", script("validate_bosh_deployer")
34
29
  end
35
30
  end
@@ -58,5 +53,16 @@ module Bosh::Bootstrap::Stages
58
53
  exit 1
59
54
  end
60
55
  end
56
+
57
+ # returns a Gemfile to be used to install bosh & other gems
58
+ def gemfile
59
+ <<-RUBY.gsub(/ /, '')
60
+ source 'https://rubygems.org'
61
+ source 'https://s3.amazonaws.com/bosh-jenkins-gems/'
62
+
63
+ gem "bosh_cli", "~> 1.5.0.pre"
64
+ gem "bosh_deployer", "~> 1.5.0.pre"
65
+ RUBY
66
+ end
61
67
  end
62
68
  end
@@ -0,0 +1,51 @@
1
+ require "json" # for inline hashes within YAML
2
+
3
+ module Bosh::Bootstrap::Stages
4
+ class SaltedPassword
5
+ attr_reader :settings
6
+
7
+ def initialize(settings)
8
+ @settings = settings
9
+ end
10
+
11
+ def commands
12
+ @commands ||= Bosh::Bootstrap::Commander::Commands.new do |server|
13
+ # use inception VM to generate a salted password (local machine may not have mkpasswd)
14
+ server.capture_value "salted password", script("convert_salted_password", "PASSWORD" => settings.bosh.password),
15
+ :settings => settings, :save_output_to_settings_key => "bosh.salted_password"
16
+ end
17
+ end
18
+
19
+ def stage_name
20
+ "stage_salted_password"
21
+ end
22
+
23
+ # Loads local script
24
+ # If +variables+, then injects KEY=VALUE environment
25
+ # variables into bash scripts.
26
+ def script(segment_name, variables={})
27
+ path = File.expand_path("../#{stage_name}/#{segment_name}", __FILE__)
28
+ if File.exist?(path)
29
+ script = File.read(path)
30
+ if variables.keys.size > 0
31
+ env_variables = variables.reject { |var| var.is_a?(Symbol) }
32
+
33
+ # inject variables into script if its bash script
34
+ inline_variables = "#!/usr/bin/env bash\n\n"
35
+ env_variables.each { |name, value| inline_variables << "#{name}='#{value}'\n" }
36
+ script.gsub!("#!/usr/bin/env bash", inline_variables)
37
+
38
+ # inject variables into script if its ruby script
39
+ inline_variables = "#!/usr/bin/env ruby\n\n"
40
+ env_variables.each { |name, value| inline_variables << "ENV['#{name}'] = '#{value}'\n" }
41
+ script.gsub!("#!/usr/bin/env ruby", inline_variables)
42
+ end
43
+ script
44
+ else
45
+ Thor::Base.shell.new.say_status "error", "Missing script lib/bosh-bootstrap/stages/#{stage_name}/#{segment_name}", :red
46
+ exit 1
47
+ end
48
+ end
49
+
50
+ end
51
+ end
@@ -15,7 +15,6 @@ module Bosh::Bootstrap::Stages
15
15
  "BOSH_HOST" => settings.bosh.ip_address,
16
16
  "BOSH_USERNAME" => settings.bosh_username,
17
17
  "BOSH_PASSWORD" => settings.bosh_password)
18
- server.cleanup "permissions", script("cleanup_permissions")
19
18
  end
20
19
  end
21
20
 
@@ -8,7 +8,7 @@ module Bosh::Bootstrap::Stages
8
8
 
9
9
  def commands
10
10
  @commands ||= Bosh::Bootstrap::Commander::Commands.new do |server|
11
- server.validate "ubuntu", script("validate_ubuntu"), :user => settings.inception.username
11
+ server.validate "ubuntu", script("validate_ubuntu"), ssh_username: settings.inception.username
12
12
  end
13
13
  end
14
14
 
@@ -5,4 +5,5 @@ require "bosh-bootstrap/stages/stage_validate_inception_vm"
5
5
  require "bosh-bootstrap/stages/stage_prepare_inception_vm"
6
6
  require "bosh-bootstrap/stages/stage_micro_bosh_deploy"
7
7
  require "bosh-bootstrap/stages/stage_setup_new_bosh"
8
+ require "bosh-bootstrap/stages/stage_salted_password"
8
9
  require "bosh-bootstrap/stages/stage_micro_bosh_delete"
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Bootstrap
3
- VERSION = "0.8.2"
3
+ VERSION = "0.9.0"
4
4
  end
5
5
  end
File without changes
@@ -0,0 +1,39 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+ require File.expand_path("../aws_helpers", __FILE__)
3
+
4
+ require "active_support/core_ext/hash/keys"
5
+
6
+ describe "AWS deployment using gems and publish stemcells" do
7
+ include FileUtils
8
+ include Bosh::Bootstrap::Helpers::SettingsSetter
9
+ include AwsHelpers
10
+
11
+ attr_reader :bosh_name
12
+
13
+ before { prepare_aws("basic", aws_region) }
14
+ after { destroy_test_constructs(bosh_name) unless keep_after_test? }
15
+
16
+ def aws_region
17
+ ENV['AWS_REGION'] || "us-west-2"
18
+ end
19
+
20
+ it "creates an EC2 inception/microbosh with the associated resources" do
21
+ create_manifest
22
+
23
+ manifest_file = home_file(".bosh_bootstrap", "manifest.yml")
24
+ File.should be_exists(manifest_file)
25
+
26
+ cmd.deploy
27
+
28
+ fog.addresses.should have(2).item
29
+ inception_ip_address = fog.addresses.first
30
+ inception_ip_address.domain.should == "standard"
31
+
32
+ inception_vms = servers_with_sg("#{bosh_name}-inception-vm")
33
+ inception_vms.size.should == 1
34
+
35
+ micrboshes = servers_with_sg(bosh_name)
36
+ micrboshes.size.should == 1
37
+ end
38
+
39
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+ require File.expand_path("../aws_helpers", __FILE__)
3
+
4
+ require "active_support/core_ext/hash/keys"
5
+
6
+ describe "AWS deployment using very latest prebuilt gems and AMIs (us-east-1 only)" do
7
+ include FileUtils
8
+ include Bosh::Bootstrap::Helpers::SettingsSetter
9
+ include AwsHelpers
10
+
11
+ attr_reader :bosh_name
12
+
13
+ before { prepare_aws("edge-prebuilt", aws_region) }
14
+ # after { destroy_test_constructs(bosh_name) unless keep_after_test? }
15
+
16
+ # Jenkins AMIs are produced for us-east-1
17
+ def aws_region
18
+ "us-east-1"
19
+ end
20
+
21
+ it "creates an EC2 inception/microbosh with the associated resources" do
22
+ create_manifest("edge-prebuilt" => true)
23
+
24
+ manifest_file = home_file(".bosh_bootstrap", "manifest.yml")
25
+ File.should be_exists(manifest_file)
26
+
27
+ cmd.deploy
28
+
29
+ ip_adresses = fog.addresses
30
+ public_ips = ip_adresses.map(&:public_ip)
31
+
32
+ inception_vms = provider.servers_with_sg("#{bosh_name}-inception-vm")
33
+ inception_vms.size.should == 1
34
+
35
+ # TODO inception VM is not getting its IP address bound correctly
36
+ # https://github.com/StarkAndWayne/bosh-bootstrap/issues/174
37
+ # public_ips.include?(inception_vms.first.public_ip_address).should be_true
38
+
39
+ micrboshes = provider.servers_with_sg(bosh_name)
40
+ micrboshes.size.should == 1
41
+ public_ips.include?(micrboshes.first.public_ip_address).should be_true
42
+
43
+ # TODO - no files in /var/vcap/store/stemcells (since it used AMI)
44
+ end
45
+
46
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+ require File.expand_path("../aws_helpers", __FILE__)
3
+
4
+ require "active_support/core_ext/hash/keys"
5
+
6
+ describe "AWS deployment using very latest prebuilt gems and stemcells (outside of us-east-1)" do
7
+ include FileUtils
8
+ include Bosh::Bootstrap::Helpers::SettingsSetter
9
+ include AwsHelpers
10
+
11
+ attr_reader :bosh_name
12
+
13
+ before { prepare_aws("edge-prebuilt", aws_region) }
14
+ # after { destroy_test_constructs(bosh_name) unless keep_after_test? }
15
+
16
+ # Jenkins AMIs are produced for us-east-1; so pick a different region to test stemcell
17
+ def aws_region
18
+ ENV['AWS_REGION'] || "us-west-2"
19
+ end
20
+
21
+ it "creates an EC2 inception/microbosh with the associated resources" do
22
+ create_manifest("edge-prebuilt" => true)
23
+
24
+ manifest_file = home_file(".bosh_bootstrap", "manifest.yml")
25
+ File.should be_exists(manifest_file)
26
+
27
+ cmd.deploy
28
+
29
+ ip_adresses = fog.addresses
30
+ public_ips = ip_adresses.map(&:public_ip)
31
+
32
+ inception_vms = provider.servers_with_sg("#{bosh_name}-inception-vm")
33
+ inception_vms.size.should == 1
34
+
35
+ # TODO inception VM is not getting its IP address bound correctly
36
+ # https://github.com/StarkAndWayne/bosh-bootstrap/issues/174
37
+ # public_ips.include?(inception_vms.first.public_ip_address).should be_true
38
+
39
+ micrboshes = provider.servers_with_sg(bosh_name)
40
+ micrboshes.size.should == 1
41
+ public_ips.include?(micrboshes.first.public_ip_address).should be_true
42
+
43
+ # TODO - no files in /var/vcap/store/stemcells (since it used AMI)
44
+ end
45
+
46
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+ require File.expand_path("../aws_helpers", __FILE__)
3
+
4
+ require "active_support/core_ext/hash/keys"
5
+
6
+ describe "AWS deployment using Bosh edge from source" do
7
+ include FileUtils
8
+ include Bosh::Bootstrap::Helpers::SettingsSetter
9
+ include AwsHelpers
10
+
11
+ attr_reader :bosh_name
12
+
13
+ before { prepare_aws("bosh-edge", aws_region) }
14
+ # after { destroy_test_constructs(bosh_name) unless keep_after_test? }
15
+
16
+ def aws_region
17
+ ENV['AWS_REGION'] || "us-west-2"
18
+ end
19
+
20
+ it "creates an EC2 inception/microbosh with the associated resources" do
21
+ create_manifest("edge" => true)
22
+
23
+ manifest_file = home_file(".bosh_bootstrap", "manifest.yml")
24
+ File.should be_exists(manifest_file)
25
+
26
+ cmd.deploy
27
+
28
+ ip_adresses = fog.addresses
29
+ public_ips = ip_adresses.map(&:public_ip)
30
+
31
+ inception_vms = provider.servers_with_sg("#{bosh_name}-inception-vm")
32
+ inception_vms.size.should == 1
33
+
34
+ # TODO inception VM is not getting its IP address bound correctly
35
+ # https://github.com/StarkAndWayne/bosh-bootstrap/issues/174
36
+ # public_ips.include?(inception_vms.first.public_ip_address).should be_true
37
+
38
+ micrboshes = provider.servers_with_sg(bosh_name)
39
+ micrboshes.size.should == 1
40
+ public_ips.include?(micrboshes.first.public_ip_address).should be_true
41
+
42
+ # TODO - microbosh stemcell in /var/vcap/store/stemcells
43
+ end
44
+
45
+ end
@@ -0,0 +1,79 @@
1
+ module AwsHelpers
2
+ def fog_credentials
3
+ @fog_credentials ||= begin
4
+ access_key = ENV['AWS_ACCESS_KEY_ID']
5
+ secret_key = ENV["AWS_SECRET_ACCESS_KEY"]
6
+ unless access_key && secret_key
7
+ raise "Please provided $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY"
8
+ end
9
+ credentials = {
10
+ :provider => 'AWS',
11
+ :aws_access_key_id => access_key,
12
+ :aws_secret_access_key => secret_key
13
+ }
14
+ end
15
+ end
16
+
17
+ def keep_after_test?
18
+ ENV['KEEP_AFTER_TEST']
19
+ end
20
+
21
+ def fog
22
+ @fog ||= connection = Fog::Compute.new(fog_credentials.merge(:region => aws_region))
23
+ end
24
+
25
+ def cmd
26
+ @cmd ||= Bosh::Bootstrap::Cli.new
27
+ end
28
+
29
+ def provider
30
+ cmd.provider
31
+ end
32
+
33
+ # used by +SettingsSetter+ to access the settings
34
+ def settings
35
+ cmd.settings
36
+ end
37
+
38
+ def prepare_aws(spec_name, aws_region)
39
+ setup_home_dir
40
+ @cmd = nil
41
+ @fog = nil
42
+ @bosh_name = "aws-#{spec_name}-#{aws_region}-#{unique_number}"
43
+ create_manifest
44
+ destroy_test_constructs(bosh_name)
45
+ end
46
+
47
+ def unique_number
48
+ ENV['UNIQUE_NUMBER'] || Random.rand(100000)
49
+ end
50
+
51
+ def create_manifest(options = {})
52
+ setting "bosh_provider", "aws"
53
+ setting "region_code", aws_region
54
+ setting "bosh_name", bosh_name
55
+ setting "inception.create_new", true
56
+ setting "bosh_username", "testuser"
57
+ setting "bosh_password", "testpass"
58
+ setting "fog_credentials", fog_credentials.stringify_keys
59
+ setting "bosh.salted_password", "pepper"
60
+ setting "bosh.persistent_disk", 16384
61
+ setting "git.name", "Dr Nic Williams"
62
+ setting "git.email", "drnicwilliams@gmail.com"
63
+ options.each { |key, value| setting(key, value) }
64
+ cmd.save_settings!
65
+ end
66
+
67
+ def destroy_test_constructs(bosh_name)
68
+ puts "Destroying everything created by previous tests..."
69
+ # destroy servers using inception-vm SG
70
+ provider.delete_security_group_and_servers("#{bosh_name}-inception-vm")
71
+ provider.delete_security_group_and_servers(bosh_name)
72
+
73
+ # TODO delete "inception" key pair? Why isn't it named for the bosh/inception VM?
74
+ provider.delete_key_pair(bosh_name)
75
+
76
+ provider.cleanup_unused_ip_addresses
77
+ end
78
+
79
+ end
data/spec/spec_helper.rb CHANGED
@@ -34,6 +34,12 @@ def setup_home_dir
34
34
  ENV['HOME'] = home_dir
35
35
  end
36
36
 
37
+ # returns the file path to a file
38
+ # in the fake $HOME folder
39
+ def home_file(*path)
40
+ File.join(ENV['HOME'], *path)
41
+ end
42
+
37
43
  RSpec.configure do |c|
38
44
  c.before(:each) do
39
45
  setup_home_dir