bosh-bootstrap 0.10.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. data/.rspec +1 -0
  2. data/.travis.yml +0 -1
  3. data/ChangeLog.md +23 -4
  4. data/Gemfile +5 -2
  5. data/Guardfile +2 -0
  6. data/README.md +209 -197
  7. data/TODO.md +55 -0
  8. data/bosh-bootstrap.gemspec +5 -12
  9. data/lib/bosh/cli/commands/bootstrap.rb +42 -0
  10. data/lib/bosh-bootstrap/cli/commands/delete.rb +26 -0
  11. data/lib/bosh-bootstrap/cli/commands/deploy.rb +89 -0
  12. data/lib/bosh-bootstrap/cli/commands/ssh.rb +32 -0
  13. data/lib/bosh-bootstrap/cli/helpers/bundle.rb +12 -0
  14. data/lib/bosh-bootstrap/cli/helpers/interactions.rb +15 -0
  15. data/lib/bosh-bootstrap/cli/helpers/settings.rb +61 -0
  16. data/lib/bosh-bootstrap/cli/helpers.rb +11 -0
  17. data/lib/bosh-bootstrap/key_pair.rb +21 -0
  18. data/lib/bosh-bootstrap/microbosh.rb +74 -0
  19. data/lib/bosh-bootstrap/microbosh_providers/aws.rb +104 -0
  20. data/lib/bosh-bootstrap/microbosh_providers/base.rb +50 -0
  21. data/lib/bosh-bootstrap/microbosh_providers/openstack.rb +61 -0
  22. data/lib/bosh-bootstrap/microbosh_providers/vsphere.rb +78 -0
  23. data/lib/bosh-bootstrap/microbosh_providers.rb +11 -0
  24. data/lib/bosh-bootstrap/network.rb +33 -0
  25. data/lib/bosh-bootstrap/network_providers/aws.rb +28 -0
  26. data/lib/bosh-bootstrap/network_providers/dummy.rb +10 -0
  27. data/lib/bosh-bootstrap/network_providers/openstack.rb +28 -0
  28. data/lib/bosh-bootstrap/network_providers.rb +11 -0
  29. data/lib/bosh-bootstrap/version.rb +1 -1
  30. data/lib/bosh-bootstrap.rb +3 -4
  31. data/spec/assets/microbosh_yml/micro_bosh.aws_ec2.yml +37 -0
  32. data/spec/assets/microbosh_yml/micro_bosh.aws_vpc.yml +39 -0
  33. data/spec/assets/microbosh_yml/micro_bosh.openstack.yml +30 -0
  34. data/spec/assets/microbosh_yml/micro_bosh.vsphere.yml +34 -0
  35. data/spec/integration/aws/aws_ec2_basic_spec.rb +39 -0
  36. data/spec/integration/aws/aws_helpers.rb +8 -61
  37. data/spec/spec_helper.rb +8 -3
  38. data/spec/support/capture_stdout.rb +18 -0
  39. data/spec/unit/cli/bootstrap_spec.rb +41 -0
  40. data/spec/unit/commands/delete_spec.rb +20 -0
  41. data/spec/unit/commands/deploy_spec.rb +64 -0
  42. data/spec/unit/commands/ssh_spec.rb +19 -0
  43. data/spec/unit/key_pair_spec.rb +13 -0
  44. data/spec/unit/microbosh_providers/aws_spec.rb +68 -0
  45. data/spec/unit/microbosh_providers/openstack_spec.rb +27 -0
  46. data/spec/unit/microbosh_providers/vsphere_spec.rb +42 -0
  47. data/spec/unit/microbosh_spec.rb +27 -0
  48. data/spec/unit/network_providers/aws_spec.rb +29 -0
  49. data/spec/unit/network_providers/openstack_spec.rb +29 -0
  50. data/spec/unit/network_spec.rb +17 -0
  51. metadata +71 -235
  52. data/CleanupCi.md +0 -8
  53. data/bin/bosh-bootstrap +0 -8
  54. data/docs/README.md +0 -3
  55. data/docs/devstack-openstack-tutorial.md +0 -215
  56. data/lib/bosh/providers/README.md +0 -5
  57. data/lib/bosh/providers/aws.rb +0 -258
  58. data/lib/bosh/providers/base_provider.rb +0 -48
  59. data/lib/bosh/providers/openstack.rb +0 -79
  60. data/lib/bosh/providers.rb +0 -21
  61. data/lib/bosh-bootstrap/cli.rb +0 -1347
  62. data/lib/bosh-bootstrap/commander/README.md +0 -47
  63. data/lib/bosh-bootstrap/commander/command.rb +0 -25
  64. data/lib/bosh-bootstrap/commander/commands.rb +0 -80
  65. data/lib/bosh-bootstrap/commander/local_server.rb +0 -68
  66. data/lib/bosh-bootstrap/commander/remote_script_command.rb +0 -51
  67. data/lib/bosh-bootstrap/commander/remote_server.rb +0 -137
  68. data/lib/bosh-bootstrap/commander/upload_command.rb +0 -17
  69. data/lib/bosh-bootstrap/commander.rb +0 -9
  70. data/lib/bosh-bootstrap/helpers/fog_setup.rb +0 -50
  71. data/lib/bosh-bootstrap/helpers/settings.rb +0 -99
  72. data/lib/bosh-bootstrap/helpers/settings_setter.rb +0 -41
  73. data/lib/bosh-bootstrap/helpers.rb +0 -3
  74. data/lib/bosh-bootstrap/stages/stage_micro_bosh_delete/bosh_micro_delete +0 -19
  75. data/lib/bosh-bootstrap/stages/stage_micro_bosh_delete.rb +0 -90
  76. data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/bosh_micro_deploy +0 -79
  77. data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy/install_key_pair_for_user +0 -23
  78. data/lib/bosh-bootstrap/stages/stage_micro_bosh_deploy.rb +0 -146
  79. data/lib/bosh-bootstrap/stages/stage_micro_bosh_download/download_micro_bosh_stemcell +0 -93
  80. data/lib/bosh-bootstrap/stages/stage_micro_bosh_download.rb +0 -139
  81. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/configure_git +0 -25
  82. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/create_vcap_user +0 -79
  83. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_base_packages +0 -30
  84. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_bosh +0 -11
  85. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_bosh_plugins +0 -25
  86. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_hub +0 -26
  87. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_ruby +0 -30
  88. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/install_useful_gems +0 -29
  89. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm/validate_bosh_deployer +0 -18
  90. data/lib/bosh-bootstrap/stages/stage_prepare_inception_vm.rb +0 -69
  91. data/lib/bosh-bootstrap/stages/stage_salted_password/convert_salted_password +0 -11
  92. data/lib/bosh-bootstrap/stages/stage_salted_password.rb +0 -51
  93. data/lib/bosh-bootstrap/stages/stage_setup_new_bosh/setup_bosh_user +0 -29
  94. data/lib/bosh-bootstrap/stages/stage_setup_new_bosh.rb +0 -51
  95. data/lib/bosh-bootstrap/stages/stage_validate_inception_vm/validate_ubuntu +0 -6
  96. data/lib/bosh-bootstrap/stages/stage_validate_inception_vm.rb +0 -39
  97. data/lib/bosh-bootstrap/stages.rb +0 -10
  98. data/spec/assets/bosh/public_stemcells/aws_micro.out +0 -7
  99. data/spec/assets/micro_bosh_yml/micro_bosh.aws_ec2.yml +0 -35
  100. data/spec/assets/micro_bosh_yml/micro_bosh.aws_vpc.yml +0 -37
  101. data/spec/integration/aws/aws_basic_spec.rb +0 -39
  102. data/spec/integration/aws/aws_edge_prebuilt_ami_spec.rb +0 -46
  103. data/spec/integration/aws/aws_edge_prebuilt_spec.rb +0 -46
  104. data/spec/integration/aws/aws_edge_spec.rb +0 -45
  105. data/spec/unit/aws_spec.rb +0 -177
  106. data/spec/unit/bosh/providers/aws_spec.rb +0 -174
  107. data/spec/unit/cli_spec.rb +0 -134
  108. data/spec/unit/cli_ssh_spec.rb +0 -95
  109. data/spec/unit/cli_upgrade_inception_spec.rb +0 -29
  110. data/spec/unit/settings_setter_spec.rb +0 -29
  111. data/vendor/cache/POpen4-0.1.4.gem +0 -0
  112. data/vendor/cache/Platform-0.4.0.gem +0 -0
  113. data/vendor/cache/activesupport-3.2.8.gem +0 -0
  114. data/vendor/cache/awesome_print-1.1.0.gem +0 -0
  115. data/vendor/cache/aws-s3-0.6.3.gem +0 -0
  116. data/vendor/cache/blobstore_client-0.4.0.gem +0 -0
  117. data/vendor/cache/bosh_cli-1.0.3.gem +0 -0
  118. data/vendor/cache/bosh_common-0.5.4.gem +0 -0
  119. data/vendor/cache/builder-3.2.0.gem +0 -0
  120. data/vendor/cache/coderay-1.0.8.gem +0 -0
  121. data/vendor/cache/diff-lcs-1.1.3.gem +0 -0
  122. data/vendor/cache/escape-0.0.4.gem +0 -0
  123. data/vendor/cache/excon-0.20.1.gem +0 -0
  124. data/vendor/cache/fog-1.8.0.gem +0 -0
  125. data/vendor/cache/formatador-0.2.4.gem +0 -0
  126. data/vendor/cache/guard-1.6.2.gem +0 -0
  127. data/vendor/cache/guard-rspec-2.4.0.gem +0 -0
  128. data/vendor/cache/highline-1.6.18.gem +0 -0
  129. data/vendor/cache/httpclient-2.2.4.gem +0 -0
  130. data/vendor/cache/i18n-0.6.1.gem +0 -0
  131. data/vendor/cache/json_pure-1.6.8.gem +0 -0
  132. data/vendor/cache/listen-0.7.2.gem +0 -0
  133. data/vendor/cache/log4r-1.1.10.gem +0 -0
  134. data/vendor/cache/lumberjack-1.0.2.gem +0 -0
  135. data/vendor/cache/method_source-0.8.1.gem +0 -0
  136. data/vendor/cache/mime-types-1.22.gem +0 -0
  137. data/vendor/cache/multi_json-1.1.0.gem +0 -0
  138. data/vendor/cache/net-scp-1.0.4.gem +0 -0
  139. data/vendor/cache/net-ssh-2.2.2.gem +0 -0
  140. data/vendor/cache/net-ssh-gateway-1.1.0.gem +0 -0
  141. data/vendor/cache/netaddr-1.5.0.gem +0 -0
  142. data/vendor/cache/nokogiri-1.5.9.gem +0 -0
  143. data/vendor/cache/open4-1.3.0.gem +0 -0
  144. data/vendor/cache/progressbar-0.9.2.gem +0 -0
  145. data/vendor/cache/pry-0.9.11.4-java.gem +0 -0
  146. data/vendor/cache/pry-0.9.11.4.gem +0 -0
  147. data/vendor/cache/rake-10.0.3.gem +0 -0
  148. data/vendor/cache/rb-fsevent-0.9.3.gem +0 -0
  149. data/vendor/cache/redcard-1.0.0.gem +0 -0
  150. data/vendor/cache/rspec-2.12.0.gem +0 -0
  151. data/vendor/cache/rspec-core-2.12.2.gem +0 -0
  152. data/vendor/cache/rspec-expectations-2.12.1.gem +0 -0
  153. data/vendor/cache/rspec-mocks-2.12.2.gem +0 -0
  154. data/vendor/cache/ruby-atmos-pure-1.0.5.gem +0 -0
  155. data/vendor/cache/ruby-hmac-0.4.0.gem +0 -0
  156. data/vendor/cache/settingslogic-2.0.9.gem +0 -0
  157. data/vendor/cache/slop-3.4.3.gem +0 -0
  158. data/vendor/cache/spoon-0.0.1.gem +0 -0
  159. data/vendor/cache/terminal-table-1.4.5.gem +0 -0
  160. data/vendor/cache/thor-0.17.0.gem +0 -0
  161. data/vendor/cache/uuidtools-2.1.3.gem +0 -0
  162. data/vendor/cache/xml-simple-1.1.2.gem +0 -0
@@ -1,90 +0,0 @@
1
- require "json" # for inline hashes within YAML
2
-
3
- module Bosh::Bootstrap::Stages
4
- class MicroBoshDelete
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
- server.delete "micro bosh", script("bosh_micro_delete",
14
- "BOSH_NAME" => settings.bosh_name)
15
- end
16
- end
17
-
18
- private
19
- def stage_name
20
- "stage_micro_bosh_delete"
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
- # inject variables into script if its bash script
32
- inline_variables = "#!/usr/bin/env bash\n\n"
33
- variables.each { |name, value| inline_variables << "#{name}='#{value}'\n" }
34
- script.gsub!("#!/usr/bin/env bash", inline_variables)
35
-
36
- # inject variables into script if its ruby script
37
- inline_variables = "#!/usr/bin/env ruby\n\n"
38
- variables.each { |name, value| inline_variables << "ENV['#{name}'] = '#{value}'\n" }
39
- script.gsub!("#!/usr/bin/env ruby", inline_variables)
40
- end
41
- script
42
- else
43
- Thor::Base.shell.new.say_status "error", "Missing script lib/bosh-bootstrap/stages/#{stage_name}/#{segment_name}", :red
44
- exit 1
45
- end
46
- end
47
-
48
- def micro_bosh_manifest
49
- name = settings.bosh_name
50
- salted_password = settings.bosh.salted_password
51
- ipaddress = settings.bosh.ip_address
52
- persistent_disk = settings.bosh.persistent_disk
53
- resources_cloud_properties = settings.bosh_resources_cloud_properties
54
- cloud_plugin = settings.bosh_provider
55
-
56
- # aws:
57
- # access_key_id: #{access_key}
58
- # secret_access_key: #{secret_key}
59
- # ec2_endpoint: ec2.#{region}.amazonaws.com
60
- # default_key_name: #{key_name}
61
- # default_security_groups: ["#{security_group}"]
62
- # ec2_private_key: /home/vcap/.ssh/#{key_name}.pem
63
- cloud_properties = settings.bosh_cloud_properties
64
-
65
- {
66
- "name" => name,
67
- "env" => { "bosh" => {"password" => salted_password}},
68
- "logging" => { "level" => "DEBUG" },
69
- "network" => { "type" => "dynamic", "vip" => ipaddress },
70
- "resources" => {
71
- "persistent_disk" => persistent_disk,
72
- "cloud_properties" => resources_cloud_properties
73
- },
74
- "cloud" => {
75
- "plugin" => cloud_plugin,
76
- "properties" => cloud_properties
77
- },
78
- "apply_spec" => {
79
- "agent" => {
80
- "blobstore" => { "address" => ipaddress },
81
- "nats" => { "address" => ipaddress }
82
- },
83
- "properties" => {
84
- "#{cloud_plugin.downcase}_registry" => { "address" => ipaddress }
85
- }
86
- }
87
- }.to_yaml.gsub(" !ruby/hash:Settingslogic", "")
88
- end
89
- end
90
- end
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Deploys a micro BOSH using "bosh micro deploy"
4
- #
5
- # Required:
6
- # * $BOSH_NAME - name of bosh deployment
7
- # (thus /var/vcap/store/microboshes/deployments/$BOSH_NAME/micro_bosh.yml exists)
8
- # * $MICRO_BOSH_STEMCELL_NAME - public stemcell name at
9
- # /var/vcap/store/stemcells/$MICRO_BOSH_STEMCELL_NAME
10
- # * $MICRO_BOSH_STEMCELL_TYPE - what type of stemcell (ami vs tgz)
11
-
12
- set -e # exit immediately if a simple command exits with a non-zero status
13
- set -u # report the usage of uninitialized variables
14
-
15
- MICRO_BOSH_STEMCELL_PATH=/var/vcap/store/stemcells/$MICRO_BOSH_STEMCELL_NAME
16
-
17
- export COLUMNS=80 # force a small width for progress bar
18
- export TMPDIR=/var/vcap/store/tmp
19
-
20
- cd /var/vcap/store/microboshes/deployments/
21
- bosh -n micro deployment $BOSH_NAME
22
-
23
- if [[ "${MICRO_BOSH_STEMCELL_NAME}" == "custom" ]]; then
24
- MICRO_BOSH_STEMCELL_PATH=$(ls -t /var/tmp/bosh/bosh_agent-*/work/work/*.tgz | sort | tail -n 1)
25
- echo "Custom stemcell path $MICRO_BOSH_STEMCELL_PATH"
26
- elif [[ "${MICRO_BOSH_STEMCELL_TYPE}" == "ami" ]]; then
27
- echo "Using AMI ${MICRO_BOSH_STEMCELL_NAME}"
28
- MICRO_BOSH_STEMCELL_PATH=${MICRO_BOSH_STEMCELL_NAME}
29
- else
30
- echo "Downloaded stemcell path $MICRO_BOSH_STEMCELL_PATH"
31
- fi
32
-
33
- if [[ -f bosh-deployments.yml ]]; then
34
- deployment=$(cat bosh-deployments.yml | yaml get instances -j | jazor "find {|inst| inst['name'] == '$BOSH_NAME' }")
35
- else
36
- deployment=""
37
- fi
38
-
39
- # if $BOSH_NAME has never been deployed before, then $deployment will be empty
40
- # if $BOSH_NAME was previously deployed but deleted then $deployment will look like:
41
- # {
42
- # "id": 1,
43
- # "name": "microbosh-aws-us-east-1",
44
- # "uuid": "bm-096bc437-b531-4260-a57f-8ea54db2f8d2",
45
- # "stemcell_cid": null,
46
- # "stemcell_name": null,
47
- # "vm_cid": null,
48
- # "disk_cid": null
49
- # }
50
- # if $BOSH_NAME has been deployed but it failed mid-way, then some of the _cid fields above will be set.
51
-
52
- echo ""
53
- echo ""
54
-
55
- if [[ "${deployment}X" == "X" ]]; then
56
- echo "Performing initial deploy of micro BOSH $BOSH_NAME"
57
- bosh -n --color micro deploy $MICRO_BOSH_STEMCELL_PATH
58
- touch $BOSH_NAME/new_bosh_deployed # to communicate with setup_bosh_user script
59
- else
60
- # determine if re-deploy, update, or delete&deploy
61
-
62
- stemcell_cid=$(echo $deployment | jazor stemcell_cid)
63
- vm_cid=$(echo $deployment | jazor vm_cid)
64
- disk_cid=$(echo $deployment | jazor disk_cid)
65
-
66
- if [[ $stemcell_cid == "" && $vm_cid == "" && $disk_cid == "" ]]; then
67
- echo "Deployment was deleted; deploying micro BOSH $BOSH_NAME again"
68
- bosh -n --color micro deploy $MICRO_BOSH_STEMCELL_PATH
69
- touch $BOSH_NAME/new_bosh_deployed # to communicate with setup_bosh_user script
70
- elif [[ $stemcell_cid == "" || $vm_cid == "" || $disk_cid == "" ]]; then
71
- echo "Deployment previously failed to complete. Deleting and deploying micro BOSH $BOSH_NAME again."
72
- bosh -n --color micro delete
73
- bosh -n --color micro deploy $MICRO_BOSH_STEMCELL_PATH
74
- touch $BOSH_NAME/new_bosh_deployed # to communicate with setup_bosh_user script
75
- else
76
- echo "Performing update deploy to micro BOSH $BOSH_NAME"
77
- bosh -n --color micro deploy $MICRO_BOSH_STEMCELL_PATH --update
78
- fi
79
- fi
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Creates a local /home/vcap/.ssh/$KEY_PAIR_NAME.pem file
4
- # from the key pair private key ($PRIVATE_KEY)
5
- #
6
- # Requires:
7
- # * ENV['KEY_PAIR_NAME']
8
- # * ENV['PRIVATE_KEY']
9
- #
10
- # Optional:
11
- # * ENV['TARGET_USER'] (default: vcap)
12
-
13
- user = ENV['TARGET_USER'] || 'vcap'
14
- key_pair_name = ENV['KEY_PAIR_NAME']
15
- private_key = ENV['PRIVATE_KEY']
16
-
17
- keyfile_path = "/home/#{user}/.ssh/#{key_pair_name}.pem"
18
- split_private_key = private_key.split(/\n/)
19
- File.open(keyfile_path, "w") do |f|
20
- split_private_key.each {|line| f.puts line}
21
- f.chmod 0600
22
- end
23
-
@@ -1,146 +0,0 @@
1
- require "json" # for inline hashes within YAML
2
-
3
- module Bosh::Bootstrap::Stages
4
- class MicroBoshDeploy
5
- attr_reader :settings
6
-
7
- def initialize(settings)
8
- @settings = settings
9
- end
10
-
11
- # TODO "aws_us_east_1" should come from settings.bosh_name
12
- def commands
13
- settings[:bosh_name] ||= "unnamed_bosh"
14
-
15
- @commands ||= Bosh::Bootstrap::Commander::Commands.new do |server|
16
- server.upload_file \
17
- "/var/vcap/store/microboshes/deployments/#{settings.bosh_name}/micro_bosh.yml",
18
- micro_bosh_manifest
19
- server.install "key pair for user", script("install_key_pair_for_user",
20
- "PRIVATE_KEY" => settings.bosh_key_pair.private_key,
21
- "KEY_PAIR_NAME" => settings.bosh_key_pair.name)
22
- server.deploy "micro bosh", script("bosh_micro_deploy",
23
- "BOSH_NAME" => settings.bosh_name,
24
- "MICRO_BOSH_STEMCELL_NAME" => settings.micro_bosh_stemcell_name,
25
- "MICRO_BOSH_STEMCELL_TYPE" => settings.micro_bosh_stemcell_type,
26
- "BOSH_HOST" => settings.bosh.ip_address,
27
- "BOSH_USERNAME" => settings.bosh_username,
28
- "BOSH_PASSWORD" => settings.bosh_password)
29
- end
30
- end
31
-
32
- def stage_name
33
- "stage_micro_bosh_deploy"
34
- end
35
-
36
- # Loads local script
37
- # If +variables+, then injects KEY=VALUE environment
38
- # variables into bash scripts.
39
- def script(segment_name, variables={})
40
- path = File.expand_path("../#{stage_name}/#{segment_name}", __FILE__)
41
- if File.exist?(path)
42
- script = File.read(path)
43
- if variables.keys.size > 0
44
- env_variables = variables.reject { |var| var.is_a?(Symbol) }
45
-
46
- # inject variables into script if its bash script
47
- inline_variables = "#!/usr/bin/env bash\n\n"
48
- env_variables.each { |name, value| inline_variables << "#{name}='#{value}'\n" }
49
- script.gsub!("#!/usr/bin/env bash", inline_variables)
50
-
51
- # inject variables into script if its ruby script
52
- inline_variables = "#!/usr/bin/env ruby\n\n"
53
- env_variables.each { |name, value| inline_variables << "ENV['#{name}'] = '#{value}'\n" }
54
- script.gsub!("#!/usr/bin/env ruby", inline_variables)
55
- end
56
- script
57
- else
58
- Thor::Base.shell.new.say_status "error", "Missing script lib/bosh-bootstrap/stages/#{stage_name}/#{segment_name}", :red
59
- exit 1
60
- end
61
- end
62
-
63
- def micro_bosh_manifest
64
- name = settings.bosh_name
65
- salted_password = settings.bosh.salted_password
66
- ipaddress = settings.bosh.ip_address
67
- persistent_disk = settings.bosh.persistent_disk
68
- resources_cloud_properties = settings.bosh_resources_cloud_properties
69
- cloud_plugin = settings.bosh_provider
70
-
71
- # aws:
72
- # access_key_id: #{access_key}
73
- # secret_access_key: #{secret_key}
74
- # ec2_endpoint: ec2.#{region}.amazonaws.com
75
- # default_key_name: #{key_name}
76
- # default_security_groups: ["#{security_group}"]
77
- # ec2_private_key: /home/vcap/.ssh/#{key_name}.pem
78
- cloud_properties = settings.bosh_cloud_properties
79
-
80
- manifest = {
81
- "name" => name,
82
- "env" => { "bosh" => {"password" => salted_password}},
83
- "logging" => { "level" => "DEBUG" },
84
- "network" => { "type" => "dynamic", "vip" => ipaddress },
85
- "resources" => {
86
- "persistent_disk" => persistent_disk,
87
- "cloud_properties" => resources_cloud_properties
88
- },
89
- "cloud" => {
90
- "plugin" => cloud_plugin,
91
- "properties" => cloud_properties
92
- },
93
- "apply_spec" => {
94
- "agent" => {
95
- "blobstore" => { "address" => ipaddress },
96
- "nats" => { "address" => ipaddress }
97
- },
98
- "properties" => {
99
- "#{cloud_plugin.downcase}_registry" => { "address" => ipaddress }
100
- }
101
- }
102
- }
103
-
104
- # Openstack settings
105
- if cloud_plugin.downcase == "openstack"
106
- # Delete OpenStack registry IP address
107
- manifest["apply_spec"]["properties"].delete("openstack_registry")
108
-
109
- # OpenStack private network label
110
- if settings.network_label
111
- manifest["network"]["label"] = settings.network_label
112
- end
113
- end
114
-
115
- manifest.to_yaml.gsub(/\s![^ ]+$/, '')
116
-
117
- # /![^ ]+\s/ removes object notation from the YAML which appears to cause problems when being interpretted by the
118
- # Ruby running on the inception vm. A before and after example would look like;
119
- #
120
- # properties: !map:Settingslogic
121
- # openstack: !map:Settingslogic
122
- # username: admin
123
- # api_key: xxxxxxxxxxxxxxxxxxx
124
- # tenant: CloudFoundry
125
- # auth_url: http://192.168.1.2:5000/v2.0/tokens
126
- # default_security_groups:
127
- # - !str:HighLine::String microbosh-openstack
128
- # default_key_name: !str:HighLine::String microbosh-openstack
129
- # private_key: /home/vcap/.ssh/microbosh-openstack.pem
130
- #
131
- # The regex strips the !Module::ClassName notation out and the result looks as it should
132
- #
133
- # properties:
134
- # openstack:
135
- # username: admin
136
- # api_key: xxxxxxxxxxxxxxxxxxx
137
- # tenant: CloudFoundry
138
- # auth_url: http://192.168.1.2:5000/v2.0/tokens
139
- # default_security_groups:
140
- # - microbosh-openstack
141
- # default_key_name: microbosh-openstack
142
- # private_key: /home/vcap/.ssh/microbosh-openstack.pem
143
-
144
- end
145
- end
146
- end
@@ -1,93 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Downloads a public stemcell for CPI into /var/vcap/store/stemcells/
4
- #
5
- # Required:
6
- # * $MICRO_BOSH_STEMCELL_NAME - public stemcell name to be downloaded
7
- # - if 'custom' the create stemcell from BOSH source
8
- # * $MICRO_BOSH_STEMCELL_TYPE - what type of stemcell (ami vs tgz)
9
- # * $PROVIDER - e.g. aws, openstack
10
- #
11
- # Optional:
12
- # * $ISO_NAME - defaults to ubuntu-10.04.4-server-amd64.iso for creating stemcell
13
-
14
- set -e # exit immediately if a simple command exits with a non-zero status
15
- set -u # report the usage of uninitialized variables
16
-
17
- if [[ "${MICRO_BOSH_STEMCELL_NAME}X" == "X" ]]; then
18
- echo 'INTERNAL ERROR: Missing $MICRO_BOSH_STEMCELL_NAME environment variable'
19
- exit 1
20
- fi
21
-
22
- STEMCELLS_DIR=/var/vcap/store/stemcells
23
- LAST_SUCCESSFUL_MICROBOSH_STEMCELL_URL=http://bosh-jenkins-artifacts.s3.amazonaws.com/last_successful_micro-bosh-stemcell-$PROVIDER.tgz
24
-
25
- if [[ "${MICRO_BOSH_STEMCELL_NAME}" == "custom" ]]; then
26
-
27
- ISO_NAME=${ISO_NAME:-ubuntu-10.04.4-server-amd64.iso}
28
-
29
- echo "Creating custom stemcell..."
30
-
31
- cd ${STEMCELLS_DIR}
32
- if [[ ! -f ${ISO_NAME} ]]; then
33
- echo "Fetching base stemcell ISO to speed up stemcell creation..."
34
- wget http://releases.ubuntu.com/lucid/${ISO_NAME}
35
- fi
36
- export UBUNTU_ISO=${STEMCELLS_DIR}/${ISO_NAME}
37
-
38
- if [[ -d /var/tmp/bosh/ ]]; then
39
- echo "But first, cleaning out previous stemcell temporary files..."
40
- rm -rf /var/tmp/bosh
41
- fi
42
-
43
- BOSH_DIR=/var/vcap/store/repos/bosh
44
- cd $(dirname $BOSH_DIR)
45
- if [[ -d bosh ]]; then
46
- echo "Updating bosh source for agent/stemcell scripts"
47
- cd bosh
48
- git pull origin master
49
- else
50
- echo "Cloning bosh source for agent/stemcell scripts"
51
- git clone https://github.com/cloudfoundry/bosh.git
52
- cd bosh
53
- fi
54
-
55
- cd $BOSH_DIR
56
- echo "Creating custom stemcell..."
57
- rm -rf .bundle
58
- bundle install --deployment
59
- bundle exec rake stemcell:micro[$PROVIDER]
60
-
61
- echo "Copying to stemcells folder..."
62
- MICRO_BOSH_STEMCELL_PATH=$(ls -t /var/tmp/bosh/bosh_agent-*/work/work/*.tgz | sort | tail -n 1)
63
- sudo mv $MICRO_BOSH_STEMCELL_PATH $STEMCELLS_DIR
64
- sudo chown vcap:vcap -R $STEMCELLS_DIR
65
- MICRO_BOSH_STEMCELL_NAME=$(basename $MICRO_BOSH_STEMCELL_PATH)
66
-
67
- elif [[ "${MICRO_BOSH_STEMCELL_TYPE}" == "edge-prebuilt" ]]; then
68
- cd $STEMCELLS_DIR
69
- echo Looking for latest microbosh stemcell at $LAST_SUCCESSFUL_MICROBOSH_STEMCELL_URL
70
- etag=$(curl -I $LAST_SUCCESSFUL_MICROBOSH_STEMCELL_URL 2>&1 | awk '/^ETag/ {print $2}' | sed -e 's/"//g')
71
- MICRO_BOSH_STEMCELL_NAME="micro_bosh-${etag}-latest.tgz"
72
- if [[ ! -f $MICRO_BOSH_STEMCELL_NAME ]]; then
73
- echo "Downloading latest microbosh stemcell, etag $etag..."
74
- curl -o $MICRO_BOSH_STEMCELL_NAME $LAST_SUCCESSFUL_MICROBOSH_STEMCELL_URL
75
- else
76
- echo "Latest microbosh stemcell with etag $etag already downloaded, skipping."
77
- fi
78
-
79
- elif [[ "${MICRO_BOSH_STEMCELL_TYPE}" == "ami" ]]; then
80
- echo "Using AMI ${MICRO_BOSH_STEMCELL_NAME}, so there is nothing to download."
81
-
82
- elif [[ -f $STEMCELLS_DIR/$MICRO_BOSH_STEMCELL_NAME ]]; then
83
- echo "Stemcell $(pwd)/$MICRO_BOSH_STEMCELL_NAME already exists."
84
-
85
- else
86
- cd $STEMCELLS_DIR
87
- echo "Downloading public stemcell $MICRO_BOSH_STEMCELL_NAME"
88
- # set $COLUMNS manually else progressbar runs `tput cols`.to_i which causes grief
89
- COLUMNS=80 bosh -n download public stemcell $MICRO_BOSH_STEMCELL_NAME
90
- fi
91
-
92
- # print name of stemcell created/downloaded to be stored back in settings
93
- echo $MICRO_BOSH_STEMCELL_NAME
@@ -1,139 +0,0 @@
1
- require "json" # for inline hashes within YAML
2
-
3
- module Bosh::Bootstrap::Stages
4
- class MicroBoshDownload
5
- attr_reader :settings
6
-
7
- def initialize(settings)
8
- @settings = settings
9
- end
10
-
11
- # TODO "aws_us_east_1" should come from settings.bosh_name
12
- def commands
13
- settings[:bosh_name] ||= "unnamed_bosh"
14
-
15
- @commands ||= Bosh::Bootstrap::Commander::Commands.new do |server|
16
- server.download "micro-bosh stemcell", script("download_micro_bosh_stemcell",
17
- "MICRO_BOSH_STEMCELL_NAME" => settings.micro_bosh_stemcell_name,
18
- "MICRO_BOSH_STEMCELL_TYPE" => settings.micro_bosh_stemcell_type,
19
- "PROVIDER" => settings.bosh_provider),
20
- :settings => settings,
21
- :save_output_to_settings_key => "micro_bosh_stemcell_name"
22
- end
23
- end
24
-
25
- def stage_name
26
- "stage_micro_bosh_download"
27
- end
28
-
29
- # Loads local script
30
- # If +variables+, then injects KEY=VALUE environment
31
- # variables into bash scripts.
32
- def script(segment_name, variables={})
33
- path = File.expand_path("../#{stage_name}/#{segment_name}", __FILE__)
34
- if File.exist?(path)
35
- script = File.read(path)
36
- if variables.keys.size > 0
37
- env_variables = variables.reject { |var| var.is_a?(Symbol) }
38
-
39
- # inject variables into script if its bash script
40
- inline_variables = "#!/usr/bin/env bash\n\n"
41
- env_variables.each { |name, value| inline_variables << "#{name}='#{value}'\n" }
42
- script.gsub!("#!/usr/bin/env bash", inline_variables)
43
-
44
- # inject variables into script if its ruby script
45
- inline_variables = "#!/usr/bin/env ruby\n\n"
46
- env_variables.each { |name, value| inline_variables << "ENV['#{name}'] = '#{value}'\n" }
47
- script.gsub!("#!/usr/bin/env ruby", inline_variables)
48
- end
49
- script
50
- else
51
- Thor::Base.shell.new.say_status "error", "Missing script lib/bosh-bootstrap/stages/#{stage_name}/#{segment_name}", :red
52
- exit 1
53
- end
54
- end
55
-
56
- def micro_bosh_manifest
57
- name = settings.bosh_name
58
- salted_password = settings.bosh.salted_password
59
- ipaddress = settings.bosh.ip_address
60
- persistent_disk = settings.bosh.persistent_disk
61
- resources_cloud_properties = settings.bosh_resources_cloud_properties
62
- cloud_plugin = settings.bosh_provider
63
-
64
- # aws:
65
- # access_key_id: #{access_key}
66
- # secret_access_key: #{secret_key}
67
- # ec2_endpoint: ec2.#{region}.amazonaws.com
68
- # default_key_name: #{key_name}
69
- # default_security_groups: ["#{security_group}"]
70
- # ec2_private_key: /home/vcap/.ssh/#{key_name}.pem
71
- cloud_properties = settings.bosh_cloud_properties
72
-
73
- manifest = {
74
- "name" => name,
75
- "env" => { "bosh" => {"password" => salted_password}},
76
- "logging" => { "level" => "DEBUG" },
77
- "network" => { "type" => "dynamic", "vip" => ipaddress },
78
- "resources" => {
79
- "persistent_disk" => persistent_disk,
80
- "cloud_properties" => resources_cloud_properties
81
- },
82
- "cloud" => {
83
- "plugin" => cloud_plugin,
84
- "properties" => cloud_properties
85
- },
86
- "apply_spec" => {
87
- "agent" => {
88
- "blobstore" => { "address" => ipaddress },
89
- "nats" => { "address" => ipaddress }
90
- },
91
- "properties" => {
92
- "#{cloud_plugin.downcase}_registry" => { "address" => ipaddress }
93
- }
94
- }
95
- }
96
-
97
- # Openstack settings
98
- if cloud_plugin.downcase == "openstack"
99
- # Delete OpenStack registry IP address
100
- manifest["apply_spec"]["properties"].delete("openstack_registry")
101
-
102
- # OpenStack private network label
103
- if settings.network_label
104
- manifest["network"]["label"] = settings.network_label
105
- end
106
- end
107
-
108
- manifest.to_yaml.gsub(/\s![^ ]+$/, '')
109
-
110
- # /![^ ]+\s/ removes object notation from the YAML which appears to cause problems when being interpretted by the
111
- # Ruby running on the inception vm. A before and after example would look like;
112
- #
113
- # properties: !map:Settingslogic
114
- # openstack: !map:Settingslogic
115
- # username: admin
116
- # api_key: xxxxxxxxxxxxxxxxxxx
117
- # tenant: CloudFoundry
118
- # auth_url: http://192.168.1.2:5000/v2.0/tokens
119
- # default_security_groups:
120
- # - !str:HighLine::String microbosh-openstack
121
- # default_key_name: !str:HighLine::String microbosh-openstack
122
- # private_key: /home/vcap/.ssh/microbosh-openstack.pem
123
- #
124
- # The regex strips the !Module::ClassName notation out and the result looks as it should
125
- #
126
- # properties:
127
- # openstack:
128
- # username: admin
129
- # api_key: xxxxxxxxxxxxxxxxxxx
130
- # tenant: CloudFoundry
131
- # auth_url: http://192.168.1.2:5000/v2.0/tokens
132
- # default_security_groups:
133
- # - microbosh-openstack
134
- # default_key_name: microbosh-openstack
135
- # private_key: /home/vcap/.ssh/microbosh-openstack.pem
136
-
137
- end
138
- end
139
- end
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Setup git configuration for the user
4
- #
5
- # Run as the user to configure
6
- #
7
- # Requires:
8
- # * $GIT_USER_NAME
9
- # * $GIT_USER_EMAIL
10
-
11
- set -e # exit immediately if a simple command exits with a non-zero status
12
-
13
- if [[ "${GIT_USER_NAME}X" == "X" ]]; then
14
- echo 'ERROR please provide $GIT_USER_NAME'
15
- exit 1
16
- fi
17
- if [[ "${GIT_USER_EMAIL}X" == "X" ]]; then
18
- echo 'ERROR please provide $GIT_USER_EMAIL'
19
- exit 1
20
- fi
21
-
22
- cd ~
23
- git config -f .gitconfig user.name "${GIT_USER_NAME}"
24
- git config -f .gitconfig user.email "${GIT_USER_EMAIL}"
25
- git config -f .gitconfig color.ui true
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Create vcap user & public keys
4
- # Re-use new public keys for root user
5
- #
6
- # Requires:
7
- # * $ORIGUSER - another local user with authorized_keys for SSH access; will be copied to vcap user
8
-
9
- if [[ $EUID -ne 0 ]]; then
10
- echo "ERROR: This script must be run as root" 1>&2
11
- exit 1
12
- fi
13
-
14
- groupadd vcap
15
- useradd vcap -m --shell /bin/bash -g vcap
16
- mkdir -p /home/vcap/.ssh
17
- chown -R vcap:vcap /home/vcap/.ssh
18
- chmod 700 /home/vcap/.ssh
19
-
20
- if [[ -f /home/vcap/.ssh/id_rsa ]]
21
- then
22
- echo "public keys for vcap already exist, skipping..."
23
- else
24
- echo "creating public keys for vcap/root user..."
25
- su -c "ssh-keygen -f ~/.ssh/id_rsa -N ''" vcap
26
- fi
27
-
28
- # Include same public keys for root user
29
- echo "copy vcap public keys to root user..."
30
- mkdir -p ~/.ssh/
31
- cp ~vcap/.ssh/id_rsa* ~/.ssh/
32
-
33
- bosh_app_dir=/var/vcap
34
- mkdir -p ${bosh_app_dir}
35
-
36
- # setup common folder for all folder/data
37
- # this is what could/should be mounted as a separate persistent disk
38
- # which is what is done for you if bosh-bootstrap creates the inception
39
- # server for you.
40
-
41
- store_dir=/var/vcap/store
42
- mkdir -p ${store_dir}
43
- chown vcap:vcap ${store_dir}
44
-
45
- # setup common folders used by bosh-bootstrap or bosh deployments
46
- for path in microboshes microboshes/deployments deployments releases repos stemcells inception tmp bosh_cache
47
- do
48
- echo "creating /var/vcap/store/${path}"
49
- mkdir -p ${store_dir}/${path}
50
- chown vcap:vcap ${store_dir}/${path}
51
- done
52
-
53
- if [[ $(grep "vcap ALL=(ALL) NOPASSWD:ALL" /etc/sudoers) == "" ]]; then
54
- echo "adding vcap to sudoers"
55
- echo "vcap ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
56
- fi
57
-
58
- echo "copying user '$ORIGUSER' authorized_keys to vcap user"
59
- cp /home/${ORIGUSER}/.ssh/authorized_keys ${bosh_app_dir}/
60
- cp /home/${ORIGUSER}/.ssh/authorized_keys /home/vcap/.ssh/authorized_keys
61
- chown vcap:vcap /home/vcap/.ssh/authorized_keys
62
- echo "copying user '$ORIGUSER' .bashrc to vcap user"
63
- cp /home/${ORIGUSER}/.bashrc /home/vcap/
64
- chown vcap:vcap /home/vcap/.bashrc
65
-
66
- if [[ $(grep "export TMPDIR" /home/vcap/.bashrc) == "" ]]; then
67
- echo 'adding $TMPDIR to .bashrc'
68
- echo "export TMPDIR=/var/vcap/store/tmp" >> /home/vcap/.bashrc
69
- fi
70
-
71
- if [[ $(grep "export EDITOR" /home/vcap/.bashrc) == "" ]]; then
72
- echo 'setting $EDITOR to vim as default'
73
- echo "export EDITOR=vim" >> /home/vcap/.bashrc
74
- fi
75
-
76
- if [[ ! -h /home/vcap/.bosh_cache ]]; then
77
- rm -rf ~vcap/.bosh_cache/
78
- ln -s /var/vcap/store/bosh_cache ~vcap/.bosh_cache
79
- fi