bosh-gen 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -4
  3. data/ChangeLog.md +24 -0
  4. data/bosh-gen.gemspec +1 -0
  5. data/lib/bosh/gen/cli.rb +6 -29
  6. data/lib/bosh/gen/generators/new_release_generator.rb +11 -0
  7. data/lib/bosh/gen/generators/new_release_generator/templates/LICENSE.md.tt +76 -0
  8. data/lib/bosh/gen/generators/new_release_generator/templates/templates/jobs.yml.tt +6 -2
  9. data/lib/bosh/gen/generators/package_apt_generator/templates/Vagrantfile +1 -2
  10. data/lib/bosh/gen/generators/package_docker_image_generator.rb +102 -0
  11. data/lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/monit.tt +5 -0
  12. data/lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/spec.tt +9 -0
  13. data/lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/templates/bin/install_ctl.tt +40 -0
  14. data/lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/templates/bin/monit_debugger +13 -0
  15. data/lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/templates/helpers/ctl_setup.sh +47 -0
  16. data/lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/templates/helpers/ctl_utils.sh +156 -0
  17. data/lib/bosh/gen/generators/package_docker_image_generator/templates/packages/%package_name%/packaging +4 -0
  18. data/lib/bosh/gen/generators/package_docker_image_generator/templates/packages/%package_name%/spec.tt +4 -0
  19. data/lib/bosh/gen/version.rb +1 -1
  20. data/spec/fixtures/releases/s3test-boshrelease/templates/jobs.yml +6 -2
  21. metadata +26 -7
  22. data/lib/bosh/gen/generators/deployment_manifest_generator.rb +0 -109
  23. data/lib/bosh/gen/generators/micro_job_generator.rb +0 -56
  24. data/lib/bosh/gen/generators/micro_job_generator/templates/jobs/micro/prepare.tt +0 -130
  25. data/spec/generators/deployment_manifest_generator_spec.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 031e74cb3b6fe9d24db20ecb0baa3a0b1edcf91a
4
- data.tar.gz: 6f7525aae7f6a47717148cf8b64fdbf42d14b805
3
+ metadata.gz: dab52b56ac409b6a60afcbbf970bf84be3e33ecc
4
+ data.tar.gz: cc58ecb46c8a5f4b17d58b8210156a76cf05851b
5
5
  SHA512:
6
- metadata.gz: dc468c3526c7b47b18be0034562b93701c91713d288c70d29066ba06d16f8f49048835bbd2e946ce879f568c4e27fd0d57a7957d38af94dac1ae4dc9f1b29c8d
7
- data.tar.gz: 29260e1fd9349b54fec9022a35a57221edfc6fd14dbd2c7ebc63e9d564bf7d4f5e1ad9b1bd0710b619ba8692edb1eb1fc2444c30ce090308ed1085b3f580ec8e
6
+ metadata.gz: c4227a283a5b12eebf89ee8179d2c493b7870cfb603058cabd5c970a0aec5ca4952b6fe7c1aa9a39074880e518caad0470d4bbd364eaa5f7d630e04e24da0ca7
7
+ data.tar.gz: 777560c1e909c7e2e0c0cdfbbd6373929a5ff47987d2b9a0dcca629751f27f17d65b55deb5d75c2d7ac850eaa88c468ad9e1e6d11f5f3705be79e4d9323ab2f3
@@ -1,10 +1,8 @@
1
1
  language: ruby
2
2
  script: bundle exec rake spec
3
3
  rvm:
4
- - ruby-1.9.3
5
- # - rbx-19mode
6
- - ruby-2.0.0
7
- - ruby-2.1.0
4
+ - ruby-2.1.6
5
+ - ruby-2.2.2
8
6
  notifications:
9
7
  email:
10
8
  recipients:
@@ -1,11 +1,35 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ v0.20.0
5
+ -------
6
+
7
+ New generator:
8
+
9
+ - `package --docker-image` - create a package that snapshots and stores a docker image
10
+
11
+ Improved generators:
12
+
13
+ - `new` - spiff templates include modern `templates:` array of `{name: job, release: release}`
14
+ - `new` - added an Apache `LICENSE.md` file which will be included in final releases
15
+ - `new --apt` - Vagrant image upgraded to trusty to match trusty stemcells [thx @cyrille-leclerc]
16
+
17
+ Removed generators:
18
+
19
+ - `manifest` in lieu of spiff templates and `./templates/make_manifest` helper
20
+ - `micro` generator as this concept is no longer needed with collocated job templates
21
+
22
+ Workarounds:
23
+
24
+ - `fog` - I've had issues with `fog-aws 0.1.2` so restricting to 0.1.1 for now.
25
+
4
26
  v0.19.0
27
+ -------
5
28
 
6
29
  - `cli-plugin` - generates a BOSH CLI plugin stub (Ruby code)
7
30
 
8
31
  v0.18.0
32
+ -------
9
33
 
10
34
  - `errand` - generates an errand-style job template
11
35
  - `copy_property` helper now in bosh-templates gem
@@ -22,6 +22,7 @@ Gem::Specification.new do |gem|
22
22
 
23
23
  gem.add_dependency "cyoi", "~> 0.10"
24
24
  gem.add_dependency "fog", "~> 1.11"
25
+ gem.add_dependency "fog-aws", "0.1.1" # 0.1.2 causes issues
25
26
  gem.add_dependency "readwritesettings", "~> 3.0"
26
27
  gem.add_dependency "activesupport", ">= 4.0", "< 5.0"
27
28
 
@@ -21,6 +21,8 @@ module Bosh
21
21
  desc "package NAME", "Create a new package"
22
22
  method_option :apt, :type => :boolean,
23
23
  :desc => "Create package using debian/ubuntu apt .debs"
24
+ method_option :docker_image, :type => :string,
25
+ :desc => "Create package from remote docker image"
24
26
  method_option :dependencies, :aliases => ['-d'], :type => :array,
25
27
  :desc => "List of package dependencies"
26
28
  method_option :files, :aliases => ['-f'], :type => :array,
@@ -32,6 +34,10 @@ module Bosh
32
34
  if options[:apt]
33
35
  require 'bosh/gen/generators/package_apt_generator'
34
36
  Bosh::Gen::Generators::PackageAptGenerator.start([name, dependencies])
37
+ elsif options[:docker_image]
38
+ docker_image = options[:docker_image]
39
+ require 'bosh/gen/generators/package_docker_image_generator'
40
+ Bosh::Gen::Generators::PackageDockerImageGenerator.start([name, docker_image])
35
41
  else
36
42
  files = options[:files] || []
37
43
  sources = options[:src] || []
@@ -81,15 +87,6 @@ module Bosh
81
87
  Bosh::Gen::Generators::ErrandGenerator.start([name, dependencies])
82
88
  end
83
89
 
84
- desc "micro [JOB]", "Create a micro job - a collection of all jobs and packages"
85
- method_option :jobs, :aliases => ['-j'], :type => :array,
86
- :desc => "Ordered list of jobs to include"
87
- def micro(job_name = "micro")
88
- specific_jobs = options[:jobs] || []
89
- require 'bosh/gen/generators/micro_job_generator'
90
- Bosh::Gen::Generators::MicroJobGenerator.start([job_name, specific_jobs])
91
- end
92
-
93
90
  desc "template JOB FILE_PATH",
94
91
  "Add a Job template (example FILE_PATH: config/httpd.conf)"
95
92
  def template(job_name, file_path)
@@ -115,26 +112,6 @@ module Bosh
115
112
  Bosh::Gen::Generators::ExtractPackageGenerator.start([source_package_path])
116
113
  end
117
114
 
118
- desc "manifest NAME PATH",
119
- "Creates a deployment manifest based on the release located at PATH"
120
- method_option :force, :type => :boolean,
121
- :desc => "Force override existing target manifest file"
122
- method_option :addresses, :aliases => ['-a'], :type => :array,
123
- :desc => "List of IP addresses available for jobs"
124
- method_option :disk, :aliases => ['-d'], :type => :string,
125
- :desc => "Attach persistent disks to VMs of specific size, e.g. 8196"
126
- method_option :jobs, :type => :array,
127
- :desc => "Specific jobs to include in manifest [default: all]"
128
- def manifest(name, release_path)
129
- release_path = File.expand_path(release_path)
130
- ip_addresses = options["addresses"] || []
131
- job_names = options["jobs"] || []
132
- flags = { :force => options["force"] || false, :disk => options[:disk] }
133
- require 'bosh/gen/generators/deployment_manifest_generator'
134
- Bosh::Gen::Generators::DeploymentManifestGenerator.start(
135
- [name, release_path, ip_addresses, job_names, flags])
136
- end
137
-
138
115
  desc "cli-plugin NAME", "Add a BOSH CLI plugin into this project"
139
116
  def cli_plugin(plugin_name)
140
117
  require 'bosh/gen/generators/bosh_cli_plugin_generator'
@@ -33,6 +33,10 @@ module Bosh::Gen
33
33
  template "README.md.tt", "README.md"
34
34
  end
35
35
 
36
+ def license
37
+ template "LICENSE.md.tt", "LICENSE.md"
38
+ end
39
+
36
40
  def rakefile
37
41
  copy_file "Rakefile"
38
42
  end
@@ -256,6 +260,13 @@ module Bosh::Gen
256
260
  @s3_credentials[key] || default
257
261
  end
258
262
 
263
+ def year
264
+ Date.today.year
265
+ end
266
+
267
+ def author
268
+ `git config --get user.name`.strip
269
+ end
259
270
  end
260
271
  end
261
272
  end
@@ -0,0 +1,76 @@
1
+ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
2
+
3
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
4
+
5
+ 1. Definitions.
6
+
7
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
8
+
9
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
10
+
11
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
12
+
13
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
14
+
15
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
16
+
17
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
18
+
19
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
20
+
21
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
22
+
23
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
24
+
25
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
26
+
27
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
28
+
29
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
30
+
31
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
32
+
33
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
34
+
35
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
36
+
37
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
38
+
39
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
40
+
41
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
42
+
43
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
44
+
45
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
46
+
47
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
48
+
49
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
50
+
51
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
52
+
53
+ END OF TERMS AND CONDITIONS
54
+
55
+ APPENDIX: How to apply the Apache License to your work.
56
+
57
+ ```
58
+ To apply the Apache License to your work, attach the following
59
+ boilerplate notice, with the fields enclosed by brackets "{}"
60
+ replaced with your own identifying information. (Don't include
61
+ the brackets!) The text should be enclosed in the appropriate
62
+ comment syntax for the file format. We also recommend that a
63
+ file or class name and description of purpose be included on the
64
+ same "printed page" as the copyright notice for easier
65
+ identification within third-party archives.
66
+ ```
67
+
68
+ Copyright <%= year %> <%= author %>
69
+
70
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
71
+
72
+ ```
73
+ http://www.apache.org/licenses/LICENSE-2.0
74
+ ```
75
+
76
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@@ -10,14 +10,18 @@ update:
10
10
 
11
11
  jobs:
12
12
  - name: <%= project_name_underscored %>_leader_z1
13
- template: <%= project_name_hyphenated %>
13
+ templates:
14
+ - name: <%= project_name_hyphenated %>
15
+ release: <%= project_name_hyphenated %>
14
16
  instances: 0
15
17
  resource_pool: small_z1
16
18
  networks: (( merge ))
17
19
  persistent_disk: 0
18
20
  properties: {}
19
21
  - name: <%= project_name_underscored %>_z1
20
- template: <%= project_name_hyphenated %>
22
+ templates:
23
+ - name: <%= project_name_hyphenated %>
24
+ release: <%= project_name_hyphenated %>
21
25
  instances: 0
22
26
  resource_pool: small_z1
23
27
  networks: (( merge ))
@@ -3,8 +3,7 @@
3
3
  Vagrant.configure('2') do |config|
4
4
 
5
5
  config.vm.hostname='boshrelease-builder'
6
- config.vm.box = "lucid64"
7
- config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
6
+ config.vm.box = "ubuntu/trusty64"
8
7
 
9
8
  # Need NFS enabled, and hence a private network for virtualbox
10
9
  # as discussed in this project's patch
@@ -0,0 +1,102 @@
1
+ require 'thor/group'
2
+
3
+ # for the #sh helper
4
+ require 'rake'
5
+ require 'rake/file_utils'
6
+
7
+ module Bosh::Gen
8
+ module Generators
9
+ class PackageDockerImageGenerator < Thor::Group
10
+ include Thor::Actions
11
+
12
+ class RakeHelper
13
+ extend FileUtils
14
+ end
15
+
16
+ argument :name
17
+ argument :docker_image
18
+
19
+ def self.source_root
20
+ File.join(File.dirname(__FILE__), "package_docker_image_generator", "templates")
21
+ end
22
+
23
+ def check_root_is_release
24
+ unless File.exist?("jobs") && File.exist?("packages")
25
+ raise Thor::Error.new("run inside a BOSH release project")
26
+ end
27
+ end
28
+
29
+ def check_name
30
+ raise Thor::Error.new("'#{name}' is not a valid BOSH id") unless name.bosh_valid_id?
31
+ end
32
+
33
+ def docker_save
34
+ FileUtils.mkdir_p("blobs/docker-images")
35
+ RakeHelper.sh "docker pull #{docker_image}"
36
+ RakeHelper.sh "docker save #{docker_image} > blobs/docker-images/#{image_filename}"
37
+ end
38
+
39
+ def jobs
40
+ directory "jobs"
41
+ end
42
+
43
+ def packages
44
+ directory "packages"
45
+ end
46
+
47
+ def readme
48
+ say "Next steps:", :green
49
+ say <<-README.gsub(/^ /, '')
50
+ 1. To use this BOSH release, first upload it and the docker release to your BOSH:
51
+ bosh upload release https://bosh.io/releases/cloudfoundry-community/consul-docker
52
+ bosh upload release https://bosh.io/d/github.com/cf-platform-eng/docker-boshrelease
53
+
54
+ 2. To use the docker image, your deployment job needs to start with the following:
55
+
56
+ jobs:
57
+ - name: some_job
58
+ templates:
59
+ # run docker daemon
60
+ - {name: docker, release: docker}
61
+ # warm docker image cache from bosh package
62
+ - {name: #{job_name}, release: #{project_name_hyphenated}}
63
+
64
+ 3. To simply run a single container, try the 'containers' job from 'docker' release
65
+
66
+ https://github.com/cloudfoundry-community/consul-docker-boshrelease/blob/master/templates/jobs.yml#L18-L40
67
+
68
+
69
+ README
70
+ end
71
+
72
+ private
73
+ def root_path
74
+ File.expand_path(".")
75
+ end
76
+
77
+ def project_name
78
+ @project_name ||= File.basename(root_path).gsub(/-(?:boshrelease|release)$/, '')
79
+ end
80
+
81
+ def project_name_hyphenated
82
+ project_name.gsub(/[^A-Za-z0-9]+/, '-')
83
+ end
84
+
85
+ def package_name
86
+ name
87
+ end
88
+
89
+ def image_name
90
+ docker_image.gsub(/\W+/, '_')
91
+ end
92
+
93
+ def image_filename
94
+ "#{image_name}.tgz"
95
+ end
96
+
97
+ def job_name
98
+ "#{image_name}_image"
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,5 @@
1
+ check process <%= job_name %>
2
+ with pidfile /var/vcap/sys/run/<%= job_name %>/<%= job_name %>.pid
3
+ start program "/var/vcap/jobs/<%= job_name %>/bin/monit_debugger install_ctl '/var/vcap/jobs/<%= job_name %>/bin/install_ctl start'"
4
+ stop program "/var/vcap/jobs/<%= job_name %>/bin/monit_debugger install_ctl '/var/vcap/jobs/<%= job_name %>/bin/install_ctl stop'"
5
+ group vcap
@@ -0,0 +1,9 @@
1
+ ---
2
+ name: <%= job_name %>
3
+ packages: [<%= package_name %>]
4
+ templates:
5
+ bin/monit_debugger: bin/monit_debugger
6
+ bin/install_ctl: bin/install_ctl
7
+ helpers/ctl_setup.sh: helpers/ctl_setup.sh
8
+ helpers/ctl_utils.sh: helpers/ctl_utils.sh
9
+ properties: {}
@@ -0,0 +1,40 @@
1
+ #!/bin/bash
2
+
3
+ set -e # exit immediately if a simple command exits with a non-zero status
4
+ set -u # report the usage of uninitialized variables
5
+
6
+ # Setup env vars and folders for the webapp_ctl script
7
+ source /var/vcap/jobs/<%= job_name %>/helpers/ctl_setup.sh '<%= job_name %>'
8
+
9
+ export PORT=${PORT:-5000}
10
+ export LANG=en_US.UTF-8
11
+
12
+ case $1 in
13
+
14
+ start)
15
+ pid_guard $PIDFILE $JOB_NAME
16
+
17
+ # store pid in $PIDFILE
18
+ echo $$ > $PIDFILE
19
+
20
+ time docker \
21
+ --host unix:///var/vcap/sys/run/docker/docker.sock \
22
+ load -i /var/vcap/packages/<%= package_name %>/<%= image_filename %>
23
+ >>$LOG_DIR/$JOB_NAME.stdout.log \
24
+ 2>>$LOG_DIR/$JOB_NAME.stderr.log
25
+
26
+ # do nothing forever
27
+ exec tail -f /dev/null
28
+ ;;
29
+
30
+ stop)
31
+ kill_and_wait $PIDFILE
32
+
33
+ ;;
34
+ *)
35
+ echo "Usage: install_ctl {start|stop}"
36
+
37
+ ;;
38
+
39
+ esac
40
+ exit 0
@@ -0,0 +1,13 @@
1
+ #!/bin/sh
2
+ # USAGE monit_debugger <label> command to run
3
+ mkdir -p /var/vcap/sys/log/monit
4
+ {
5
+ echo "MONIT-DEBUG date"
6
+ date
7
+ echo "MONIT-DEBUG env"
8
+ env
9
+ echo "MONIT-DEBUG $@"
10
+ $2 $3 $4 $5 $6 $7
11
+ R=$?
12
+ echo "MONIT-DEBUG exit code $R"
13
+ } >/var/vcap/sys/log/monit/monit_debugger.$1.log 2>&1
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Setup env vars and folders for the ctl script
4
+ # This helps keep the ctl script as readable
5
+ # as possible
6
+
7
+ # Usage options:
8
+ # source /var/vcap/jobs/foobar/helpers/ctl_setup.sh JOB_NAME OUTPUT_LABEL
9
+ # source /var/vcap/jobs/foobar/helpers/ctl_setup.sh foobar
10
+ # source /var/vcap/jobs/foobar/helpers/ctl_setup.sh foobar foobar
11
+ # source /var/vcap/jobs/foobar/helpers/ctl_setup.sh foobar nginx
12
+
13
+ set -e # exit immediately if a simple command exits with a non-zero status
14
+ set -u # report the usage of uninitialized variables
15
+
16
+ JOB_NAME=$1
17
+ output_label=${1:-JOB_NAME}
18
+
19
+ export JOB_DIR=/var/vcap/jobs/$JOB_NAME
20
+ chmod 755 $JOB_DIR # to access file via symlink
21
+
22
+ source $JOB_DIR/helpers/ctl_utils.sh
23
+ redirect_output ${output_label}
24
+
25
+ export HOME=${HOME:-/home/vcap}
26
+
27
+ # Add all packages' /bin & /sbin into $PATH
28
+ for package_bin_dir in $(ls -d /var/vcap/packages/*/*bin)
29
+ do
30
+ export PATH=${package_bin_dir}:$PATH
31
+ done
32
+
33
+ # Setup log, run and tmp folders
34
+
35
+ export RUN_DIR=/var/vcap/sys/run/$JOB_NAME
36
+ export LOG_DIR=/var/vcap/sys/log/$JOB_NAME
37
+ export TMP_DIR=/var/vcap/sys/tmp/$JOB_NAME
38
+ export STORE_DIR=/var/vcap/store/$JOB_NAME
39
+ for dir in $RUN_DIR $LOG_DIR $TMP_DIR $STORE_DIR
40
+ do
41
+ mkdir -p ${dir}
42
+ chown vcap:vcap ${dir}
43
+ chmod 775 ${dir}
44
+ done
45
+ export TMPDIR=$TMP_DIR
46
+
47
+ PIDFILE=$RUN_DIR/$JOB_NAME.pid
@@ -0,0 +1,156 @@
1
+ # Helper functions used by ctl scripts
2
+
3
+ # links a job file (probably a config file) into a package
4
+ # Example usage:
5
+ # link_job_file_to_package config/redis.yml [config/redis.yml]
6
+ # link_job_file_to_package config/wp-config.php wp-config.php
7
+ link_job_file_to_package() {
8
+ source_job_file=$1
9
+ target_package_file=${2:-$source_job_file}
10
+ full_package_file=$WEBAPP_DIR/${target_package_file}
11
+
12
+ link_job_file ${source_job_file} ${full_package_file}
13
+ }
14
+
15
+ # links a job file (probably a config file) somewhere
16
+ # Example usage:
17
+ # link_job_file config/bashrc /home/vcap/.bashrc
18
+ link_job_file() {
19
+ source_job_file=$1
20
+ target_file=$2
21
+ full_job_file=$JOB_DIR/${source_job_file}
22
+
23
+ echo link_job_file ${full_job_file} ${target_file}
24
+ if [[ ! -f ${full_job_file} ]]
25
+ then
26
+ echo "file to link ${full_job_file} does not exist"
27
+ else
28
+ # Create/recreate the symlink to current job file
29
+ # If another process is using the file, it won't be
30
+ # deleted, so don't attempt to create the symlink
31
+ mkdir -p $(dirname ${target_file})
32
+ ln -nfs ${full_job_file} ${target_file}
33
+ fi
34
+ }
35
+
36
+ # If loaded within monit ctl scripts then pipe output
37
+ # If loaded from 'source ../utils.sh' then normal STDOUT
38
+ redirect_output() {
39
+ SCRIPT=$1
40
+ mkdir -p /var/vcap/sys/log/monit
41
+ exec 1>> /var/vcap/sys/log/monit/$SCRIPT.log
42
+ exec 2>> /var/vcap/sys/log/monit/$SCRIPT.err.log
43
+ }
44
+
45
+ pid_guard() {
46
+ pidfile=$1
47
+ name=$2
48
+
49
+ if [ -f "$pidfile" ]; then
50
+ pid=$(head -1 "$pidfile")
51
+
52
+ if [ -n "$pid" ] && [ -e /proc/$pid ]; then
53
+ echo "$name is already running, please stop it first"
54
+ exit 1
55
+ fi
56
+
57
+ echo "Removing stale pidfile..."
58
+ rm $pidfile
59
+ fi
60
+ }
61
+
62
+ wait_pid() {
63
+ pid=$1
64
+ try_kill=$2
65
+ timeout=${3:-0}
66
+ force=${4:-0}
67
+ countdown=$(( $timeout * 10 ))
68
+
69
+ echo wait_pid $pid $try_kill $timeout $force $countdown
70
+ if [ -e /proc/$pid ]; then
71
+ if [ "$try_kill" = "1" ]; then
72
+ echo "Killing $pidfile: $pid "
73
+ kill $pid
74
+ fi
75
+ while [ -e /proc/$pid ]; do
76
+ sleep 0.1
77
+ [ "$countdown" != '0' -a $(( $countdown % 10 )) = '0' ] && echo -n .
78
+ if [ $timeout -gt 0 ]; then
79
+ if [ $countdown -eq 0 ]; then
80
+ if [ "$force" = "1" ]; then
81
+ echo -ne "\nKill timed out, using kill -9 on $pid... "
82
+ kill -9 $pid
83
+ sleep 0.5
84
+ fi
85
+ break
86
+ else
87
+ countdown=$(( $countdown - 1 ))
88
+ fi
89
+ fi
90
+ done
91
+ if [ -e /proc/$pid ]; then
92
+ echo "Timed Out"
93
+ else
94
+ echo "Stopped"
95
+ fi
96
+ else
97
+ echo "Process $pid is not running"
98
+ echo "Attempting to kill pid anyway..."
99
+ kill $pid
100
+ fi
101
+ }
102
+
103
+ wait_pidfile() {
104
+ pidfile=$1
105
+ try_kill=$2
106
+ timeout=${3:-0}
107
+ force=${4:-0}
108
+ countdown=$(( $timeout * 10 ))
109
+
110
+ if [ -f "$pidfile" ]; then
111
+ pid=$(head -1 "$pidfile")
112
+ if [ -z "$pid" ]; then
113
+ echo "Unable to get pid from $pidfile"
114
+ exit 1
115
+ fi
116
+
117
+ wait_pid $pid $try_kill $timeout $force
118
+
119
+ rm -f $pidfile
120
+ else
121
+ echo "Pidfile $pidfile doesn't exist"
122
+ fi
123
+ }
124
+
125
+ kill_and_wait() {
126
+ pidfile=$1
127
+ # Monit default timeout for start/stop is 30s
128
+ # Append 'with timeout {n} seconds' to monit start/stop program configs
129
+ timeout=${2:-25}
130
+ force=${3:-1}
131
+ if [[ -f ${pidfile} ]]
132
+ then
133
+ wait_pidfile $pidfile 1 $timeout $force
134
+ else
135
+ # TODO assume $1 is something to grep from 'ps ax'
136
+ pid="$(ps auwwx | grep "$1" | awk '{print $2}')"
137
+ wait_pid $pid 1 $timeout $force
138
+ fi
139
+ }
140
+
141
+ check_nfs_mount() {
142
+ opts=$1
143
+ exports=$2
144
+ mount_point=$3
145
+
146
+ if grep -qs $mount_point /proc/mounts; then
147
+ echo "Found NFS mount $mount_point"
148
+ else
149
+ echo "Mounting NFS..."
150
+ mount $opts $exports $mount_point
151
+ if [ $? != 0 ]; then
152
+ echo "Cannot mount NFS from $exports to $mount_point, exiting..."
153
+ exit 1
154
+ fi
155
+ fi
156
+ }
@@ -0,0 +1,4 @@
1
+ set -e # exit immediately if a simple command exits with a non-zero status
2
+ set -u # report the usage of uninitialized variables
3
+
4
+ cp -a docker-images/* $BOSH_INSTALL_TARGET
@@ -0,0 +1,4 @@
1
+ ---
2
+ name: <%= package_name %>
3
+ dependencies: []
4
+ files: [docker-images/<%= image_filename %>]
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Gen
3
- VERSION = "0.19.0"
3
+ VERSION = "0.20.0"
4
4
  end
5
5
  end
@@ -10,12 +10,16 @@ update:
10
10
 
11
11
  jobs:
12
12
  - name: s3test_leader_z1
13
- template: s3test
13
+ templates:
14
+ - name: s3test
15
+ release: s3test
14
16
  instances: 0
15
17
  resource_pool: small_z1
16
18
  networks: (( merge ))
17
19
  - name: s3test_z1
18
- template: s3test
20
+ templates:
21
+ - name: s3test
22
+ release: s3test
19
23
  instances: 0
20
24
  resource_pool: small_z1
21
25
  networks: (( merge ))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-07 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.11'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fog-aws
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.1.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.1.1
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: readwritesettings
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +194,6 @@ files:
180
194
  - lib/bosh/gen/cli.rb
181
195
  - lib/bosh/gen/generators/bosh_cli_plugin_generator.rb
182
196
  - lib/bosh/gen/generators/bosh_cli_plugin_generator/templates/lib/bosh/cli/commands/%underscore_plugin_name%.rb.tt
183
- - lib/bosh/gen/generators/deployment_manifest_generator.rb
184
197
  - lib/bosh/gen/generators/errand_generator.rb
185
198
  - lib/bosh/gen/generators/errand_generator/templates/.gitkeep
186
199
  - lib/bosh/gen/generators/errand_generator/templates/jobs/%job_name%/monit.tt
@@ -216,9 +229,8 @@ files:
216
229
  - lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/helpers/ctl_setup.sh
217
230
  - lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/helpers/ctl_utils.sh
218
231
  - lib/bosh/gen/generators/job_template_generator.rb
219
- - lib/bosh/gen/generators/micro_job_generator.rb
220
- - lib/bosh/gen/generators/micro_job_generator/templates/jobs/micro/prepare.tt
221
232
  - lib/bosh/gen/generators/new_release_generator.rb
233
+ - lib/bosh/gen/generators/new_release_generator/templates/LICENSE.md.tt
222
234
  - lib/bosh/gen/generators/new_release_generator/templates/README.md.tt
223
235
  - lib/bosh/gen/generators/new_release_generator/templates/Rakefile
224
236
  - lib/bosh/gen/generators/new_release_generator/templates/blobs/.gitkeep
@@ -246,6 +258,15 @@ files:
246
258
  - lib/bosh/gen/generators/package_apt_generator/templates/src/apt/%name%/aptfile.tt
247
259
  - lib/bosh/gen/generators/package_apt_generator/templates/src/apt/%name%/profile.sh.tt
248
260
  - lib/bosh/gen/generators/package_apt_generator/templates/src/apt/fetch_debs.sh
261
+ - lib/bosh/gen/generators/package_docker_image_generator.rb
262
+ - lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/monit.tt
263
+ - lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/spec.tt
264
+ - lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/templates/bin/install_ctl.tt
265
+ - lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/templates/bin/monit_debugger
266
+ - lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/templates/helpers/ctl_setup.sh
267
+ - lib/bosh/gen/generators/package_docker_image_generator/templates/jobs/%job_name%/templates/helpers/ctl_utils.sh
268
+ - lib/bosh/gen/generators/package_docker_image_generator/templates/packages/%package_name%/packaging
269
+ - lib/bosh/gen/generators/package_docker_image_generator/templates/packages/%package_name%/spec.tt
249
270
  - lib/bosh/gen/generators/package_generator.rb
250
271
  - lib/bosh/gen/generators/package_generator/templates/.gitkeep
251
272
  - lib/bosh/gen/generators/package_source_generator.rb
@@ -323,7 +344,6 @@ files:
323
344
  - spec/fixtures/releases/some_dev_releases/dev_releases/myrelease-1.yml
324
345
  - spec/fixtures/releases/some_dev_releases/dev_releases/myrelease-10.yml
325
346
  - spec/fixtures/releases/some_dev_releases/dev_releases/myrelease-2.yml
326
- - spec/generators/deployment_manifest_generator_spec.rb
327
347
  - spec/generators/job_generator_spec.rb
328
348
  - spec/generators/new_release_generator_spec.rb
329
349
  - spec/models/bosh_config_spec.rb
@@ -422,7 +442,6 @@ test_files:
422
442
  - spec/fixtures/releases/some_dev_releases/dev_releases/myrelease-1.yml
423
443
  - spec/fixtures/releases/some_dev_releases/dev_releases/myrelease-10.yml
424
444
  - spec/fixtures/releases/some_dev_releases/dev_releases/myrelease-2.yml
425
- - spec/generators/deployment_manifest_generator_spec.rb
426
445
  - spec/generators/job_generator_spec.rb
427
446
  - spec/generators/new_release_generator_spec.rb
428
447
  - spec/models/bosh_config_spec.rb
@@ -1,109 +0,0 @@
1
- require 'yaml'
2
- require 'thor/group'
3
- require 'bosh/template/property_helper'
4
-
5
- module Bosh::Gen
6
- module Generators
7
- class DeploymentManifestGenerator < Thor::Group
8
- include Thor::Actions
9
- include Bosh::Template::PropertyHelper
10
-
11
- argument :name
12
- argument :release_path
13
- argument :ip_addresses, :type => :array
14
- argument :requested_jobs, :type => :array
15
- argument :flags, :type => :hash
16
-
17
- def check_release_path_is_release
18
- unless File.exist?(release_path)
19
- raise Thor::Error.new("target path '#{release_path}' doesn't exist")
20
- end
21
- FileUtils.chdir(release_path) do
22
- unless File.exist?("jobs") && File.exist?("packages")
23
- raise Thor::Error.new("target path '#{release_path}' is not a BOSH release project")
24
- end
25
- end
26
- end
27
-
28
- def check_valid_requested_jobs
29
- if jobs.empty?
30
- raise Thor::Error.new("No valid jobs specified from #{detect_jobs.inspect}")
31
- end
32
- end
33
-
34
- # Create a deployment manifest (initially for AWS only)
35
- def create_deployment_manifest
36
- cloud_properties = {
37
- "instance_type" => "m1.small",
38
- }
39
- cloud_properties["persistent_disk"] = flags[:disk] if flags[:disk]
40
- cloud_properties["static_ips"] = ip_addresses
41
- director_uuid = Bosh::Gen::Models::BoshConfig.new.target_uuid
42
- manifest = Bosh::Gen::Models::DeploymentManifest.new(
43
- name, director_uuid,
44
- release_properties, cloud_properties, default_properties)
45
- manifest.jobs = job_manifests
46
- create_file manifest_file_name, manifest.to_yaml, :force => flags[:force]
47
- end
48
-
49
- def setup_bosh_deployment_target
50
- run "bosh deployment #{manifest_file_name}"
51
- end
52
-
53
- private
54
- def release_detector
55
- @release_detector ||= Bosh::Gen::Models::ReleaseDetection.new(release_path)
56
- end
57
-
58
- # Whether +name+ contains .yml suffix or nor, returns a .yml filename for manifest to be generated
59
- def manifest_file_name
60
- basename = "#{name}.yml"
61
- end
62
-
63
- def job_manifests
64
- jobs.map do |job_name|
65
- {
66
- "name" => job_name
67
- }
68
- end
69
- end
70
-
71
- # Return list of job names
72
- def detect_jobs
73
- release_detector.latest_dev_release_job_names
74
- end
75
-
76
- def jobs
77
- job_names = if !requested_jobs || requested_jobs.size == 0
78
- detect_jobs
79
- else
80
- requested_jobs & detect_jobs
81
- end
82
- end
83
-
84
- # The "release" aspect of the manifest, which has two keys: name, version
85
- def release_properties
86
- release_detector.latest_dev_release_properties
87
- end
88
-
89
- # Default properties for manifest, based on each job's spec's properties hash, if present
90
- # For example, a job's spec may include something like:
91
- # properties:
92
- # mysql.password:
93
- # default: mypassword
94
- # description: Password for mysql server
95
- def default_properties
96
- properties = {}
97
- jobs.each do |job_name|
98
- spec = YAML.load_file(File.join(release_path, "jobs", job_name, "spec"))
99
- if spec_properties = spec["properties"]
100
- spec_properties.each_pair do |name, definition|
101
- copy_property(properties, spec_properties, name, definition["default"])
102
- end
103
- end
104
- end
105
- properties
106
- end
107
- end
108
- end
109
- end
@@ -1,56 +0,0 @@
1
- require 'yaml'
2
- require 'thor/group'
3
-
4
- module Bosh::Gen
5
- module Generators
6
- class MicroJobGenerator < Thor::Group
7
- include Thor::Actions
8
-
9
- argument :job_name
10
- argument :specific_jobs, :type => :array
11
-
12
- def self.source_root
13
- File.join(File.dirname(__FILE__), "micro_job_generator", "templates")
14
- end
15
-
16
- def check_root_is_release
17
- unless File.exist?("jobs") && File.exist?("packages")
18
- raise Thor::Error.new("run inside a BOSH release project")
19
- end
20
- end
21
-
22
- def create_job
23
- directory "jobs/micro", "jobs/#{job_name}"
24
- chmod "jobs/#{job_name}/prepare", 0755
25
- end
26
-
27
- def prepare_spec_defaults_all_jobs
28
- jobs = if specific_jobs.size > 0
29
- specific_jobs
30
- else
31
- Dir[File.expand_path("jobs/*")].map {|job| File.basename(job) } - [job_name]
32
- end
33
- spec = { "jobs" => jobs }
34
- create_file "jobs/#{job_name}/prepare_spec", YAML.dump(spec)
35
- end
36
-
37
- def gitignore
38
- append_file ".gitignore", <<-IGNORE.gsub(/^\s{8}/, '')
39
- jobs/#{job_name}/monit
40
- jobs/#{job_name}/spec
41
- jobs/#{job_name}/templates/
42
- IGNORE
43
- end
44
-
45
- def readme
46
- say ""
47
- say "Edit "; say "jobs/#{job_name}/prepare_spec ", :yellow
48
- say "with ordered list of jobs to include"
49
- say "in micro job. The order of jobs implicitly specifies the order in"
50
- say "which they are started."
51
- say ""
52
- say ""
53
- end
54
- end
55
- end
56
- end
@@ -1,130 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- require 'fileutils'
4
- require 'yaml'
5
- require 'erb'
6
-
7
- TEMPLATES = "templates"
8
- OVERRIDE = "override"
9
-
10
- MICRO_JOB_NAME="<%= job_name %>"
11
-
12
- def job_dir(job)
13
- File.expand_path("../../#{job}", __FILE__)
14
- end
15
-
16
- PREPARE_SPEC = YAML.load_file(File.expand_path("../prepare_spec", __FILE__))
17
-
18
- # Order of jobs, implicitly specifies the order in which they are started
19
- jobs = PREPARE_SPEC["jobs"]
20
-
21
- spec = {
22
- "name" => MICRO_JOB_NAME,
23
- "templates" => {
24
- "post_install" => "bin/post_install"
25
- },
26
- "packages" => []
27
- }
28
-
29
- monit = []
30
-
31
- # make sure we start with an empty directory, as it will stop if
32
- # there are any conflicts when populating the template dir
33
- FileUtils.rm_rf(TEMPLATES)
34
- FileUtils.mkdir(TEMPLATES)
35
-
36
- jobs.each do |job|
37
- # concatenate monit file
38
- override = File.join(OVERRIDE, "monit", job)
39
- if File.exist?(override)
40
- monit_file = override
41
- else
42
- monit_file = "#{job_dir(job)}/monit"
43
- end
44
- File.open(monit_file) do |file|
45
- monit += file.readlines
46
- monit << "\n"
47
- end
48
-
49
- # copy templates from:
50
- # * templates/<template_name>
51
- # * templates/<template_dir>/<template_name>
52
- Dir.glob("#{job_dir(job)}/templates/**/*").each do |file|
53
- next if File.directory?(file)
54
-
55
- template_name = File.basename(file)
56
- template_dir = File.basename(File.dirname(file))
57
- # check if template file is in a nested dir
58
- # if 'templates' then its not
59
- if template_dir == "templates"
60
- override = File.join(OVERRIDE, job, template_name)
61
- dest = File.join(TEMPLATES, job)
62
- else
63
- override = File.join(OVERRIDE, job, template_dir, template_name)
64
- dest = File.join(TEMPLATES, job, template_dir)
65
- end
66
- FileUtils.mkdir_p(dest) unless File.directory?(dest)
67
-
68
- if File.exist?(File.join(dest, template_name))
69
- puts "File conflict for job #{job}: #{template_name}"
70
- exit 1
71
- elsif File.exist?(override)
72
- FileUtils.cp(override, dest)
73
- else
74
- FileUtils.cp(file, dest)
75
- end
76
- end
77
-
78
- # build spec
79
- s = YAML.load_file("#{job_dir(job)}/spec")
80
- spec["packages"] += s["packages"]
81
- s["templates"].each do |src, dst|
82
- spec["templates"]["#{job}/#{src}"] = "#{job}/#{dst}"
83
- end
84
- end
85
-
86
- # write out the concatenated monit file
87
- File.open("monit", "w") do |file|
88
- file.puts monit.join
89
- end
90
-
91
-
92
- # write out spec file
93
- spec["packages"] = spec["packages"].uniq
94
- File.open("spec", "w") do |file|
95
- file.puts spec.to_yaml
96
- end
97
-
98
-
99
-
100
- # generate post_install file with all jobs
101
- # it creates links from
102
- # jobs/micro/<job>/bin/foo to jobs/<job>/bin/foo
103
- # jobs/micro/<job>/config/bar to jobs/<job>/config/bar
104
- post_install = <<POST_INSTALL
105
- #!/bin/sh
106
-
107
- for DIR in /var/vcap/jobs /var/vcap/data/jobs; do
108
- cd $DIR
109
- for JOB in <%%= jobs.join(" ") %>; do
110
- mkdir -p ${JOB}/bin ${JOB}/config ${JOB}/data ${JOB}/helpers
111
- for FILE in <%%= MICRO_JOB_NAME %>/$JOB/bin/*; do
112
- ln -nsf /var/vcap/jobs/$FILE $JOB/bin
113
- done
114
- for FILE in <%%= MICRO_JOB_NAME %>/$JOB/config/*; do
115
- ln -nsf /var/vcap/jobs/$FILE $JOB/config
116
- done
117
- for FILE in <%%= MICRO_JOB_NAME %>/$JOB/data/*; do
118
- ln -nsf /var/vcap/jobs/$FILE $JOB/data
119
- done
120
- for FILE in <%%= MICRO_JOB_NAME %>/$JOB/helpers/*; do
121
- ln -nsf /var/vcap/jobs/$FILE $JOB/helpers
122
- done
123
- done
124
- done
125
- POST_INSTALL
126
-
127
- File.open("templates/post_install", "w") do |file|
128
- template = ERB.new(post_install)
129
- file.puts template.result
130
- end
@@ -1,38 +0,0 @@
1
- require "spec_helper"
2
- require "bosh/gen/generators/deployment_manifest_generator"
3
-
4
- # in a tmp folder:
5
- # * run generator
6
- # * deployment manifest created
7
-
8
- # generates dpeloyment manifest for a target release
9
- describe Bosh::Gen::Generators::DeploymentManifestGenerator do
10
-
11
- xit "creates deployment manifest with properties" do
12
- setup_project_release("bosh-sample-release")
13
- release_folder = File.expand_path("../../fixtures/releases/bosh-sample-release", __FILE__)
14
- in_home_folder do
15
- generate_manifest("wordpress", release_folder)
16
- expect(File.exist?("wordpress.yml")).to eq(true)
17
-
18
- manifest = YAML.load_file("wordpress.yml")
19
- properties = manifest["properties"]
20
- properties.wont_be_nil "manifest properties must be set"
21
- properties["mysql"].wont_be_nil
22
- properties["mysql"]["password"].must_equal 'mysqlpassword'
23
- end
24
- end
25
-
26
- it "checks for numerics in filenames/properties" do
27
- release_folder = File.expand_path("../../tmp", __FILE__)
28
- setup_project_release("s3test-boshrelease")
29
- expect(File.exist?(File.join(@active_project_folder, "jobs/s3test/spec"))).to eq true
30
-
31
- dev = YAML.load_file(File.join(@active_project_folder, "config/dev.yml"))
32
- expect(dev).not_to be_nil
33
- expect(dev["dev_name"]).to eq "s3test"
34
-
35
- deployment = YAML.load_file(File.join(@active_project_folder, "templates/deployment.yml"))
36
- expect(deployment["compilation"]["network"]).to eq("s3test1")
37
- end
38
- end