bosh-gen 0.96.0 → 0.97.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ece591a7a7c0e87b516792c42779191fc9fc092
4
- data.tar.gz: b08c4f05ca34ad67ad3efc30f81b9f97a94c8466
3
+ metadata.gz: 3b7692351ac5b6596e8b513a4798897bdbc89018
4
+ data.tar.gz: c2c2156c41a4127e0f4ab4a918f71d7ac18c2f7f
5
5
  SHA512:
6
- metadata.gz: a6820845800b4a4abfbc00a6b60e31a7bdb8d01c636d30a30dd908a51f93c239f0de675e3978fe612ebb0f20e7b280dd82c1019385f9ede9ede3b32a65091cd7
7
- data.tar.gz: f163a68e509785684c0c5057853d28504f9a10e2de44fa26e4011c2df600ad77bd0e967acdbbc87acaa61e866efb4e2ecf49515a47cd4ca0d317c2e184de5e27
6
+ metadata.gz: 4f4f02ce3983d769d5ee81e239f89f05daf823d44b394e2f5635e73322d05fa9b91a0b37ae6acdb46f887e560bf8ded11c31d024900a5253a0e96c7de9b20ab1
7
+ data.tar.gz: 2f7fe7100365e577267af10cfa69c4fa7ec5b56da1134db7130b5664038bb2f5c62d862b3a56d5fd590958ed9b7eb1b0c592265742e73b4e653f9aa05639c6f5
@@ -5,9 +5,6 @@ exec 2>&1
5
5
  set -e # exit immediately if a simple command exits with a non-zero status
6
6
  set -u # report the usage of uninitialized variables
7
7
 
8
- # Setup env vars and folders for the errand script
9
- source /var/vcap/jobs/<%= job_name %>/helpers/ctl_setup.sh '<%= job_name %>'
10
-
11
8
  ############################################################################
12
9
 
13
10
  # put your errand steps here...
@@ -12,4 +12,3 @@ processes:
12
12
  open_files: 1024
13
13
 
14
14
  # example at https://github.com/cloudfoundry-incubator/bpm-release/blob/master/jobs/bpm-test-agent/templates/bpm.yml.erb
15
- # example at https://github.com/cloudfoundry-incubator/bpm-release/blob/master/jobs/bpm-test-agent/templates/bpm.yml.erb
@@ -37,14 +37,11 @@ module Bosh::Gen
37
37
  template "LICENSE.md.tt", "LICENSE.md"
38
38
  end
39
39
 
40
- def rakefile
41
- copy_file "Rakefile"
42
- end
43
-
44
40
  def directories
45
41
  %w[jobs packages src blobs manifests].each do |dir|
46
42
  directory dir
47
43
  end
44
+ chmod 'manifests/operators/pick-from-cloud-config.sh', 0755
48
45
  end
49
46
 
50
47
  def blobs_yaml
@@ -17,7 +17,7 @@ If your BOSH does not have Credhub/Config Server, then remember `--vars-store` t
17
17
 
18
18
  ### Update
19
19
 
20
- When new versions of `redis-boshrelease` are released the `manifests/redis.yml` file will be updated. This means you can easily `git pull` and `bosh deploy` to upgrade.
20
+ When new versions of `<%= project_name %>-boshrelease` are released the `manifests/<%= project_name %>.yml` file will be updated. This means you can easily `git pull` and `bosh deploy` to upgrade.
21
21
 
22
22
  ```
23
23
  export BOSH_ENVIRONMENT=<bosh-alias>
@@ -25,5 +25,5 @@ export BOSH_DEPLOYMENT=<%= project_name %>
25
25
  cd <%= project_name %>-boshrelease
26
26
  git pull
27
27
  cd -
28
- bosh deploy <%= project_name %>-boshrelease/manifests/redis.yml
28
+ bosh deploy <%= project_name %>-boshrelease/manifests/<%= project_name %>.yml
29
29
  ```
@@ -0,0 +1,38 @@
1
+ #!/bin/bash
2
+
3
+ # The base manifests/<%= project_name %>.yml assumes that your `bosh cloud-config` contains
4
+ # "vm_type" and "networks" named "default". Its quite possible you don't have this.
5
+ # This script will select the first "vm_types" and first "networks" to use in
6
+ # your deployment. It will print to stderr the choices it made.
7
+ #
8
+ # Usage:
9
+ # bosh deploy manifests/<%= project_name %>.yml -o <(./manifests/operators/pick-from-cloud-config.sh)
10
+
11
+ : ${BOSH_ENVIRONMENT:?required}
12
+
13
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
14
+ cd $DIR/../..
15
+
16
+ instance_groups=$(bosh int <(cat manifests/*.yml) $@ --path /instance_groups | grep "^ name:" | awk '{print $2}' | sort | uniq)
17
+ cloud_config=$(bosh cloud-config)
18
+ if [[ -z ${cloud_config} ]]; then
19
+ echo "BOSH env missing a cloud-config"
20
+ exit 1
21
+ fi
22
+ vm_type=$(bosh int <(echo "$cloud_config") --path /vm_types/0/name)
23
+ network=$(bosh int <(echo "$cloud_config") --path /networks/0/name)
24
+
25
+ >&2 echo "vm_type: ${vm_type}, network: ${network}"
26
+
27
+ for ig in $instance_groups; do
28
+ cat <<YAML
29
+ - type: replace
30
+ path: /instance_groups/name=${ig}/networks/name=default/name
31
+ value: ${network}
32
+
33
+ - type: replace
34
+ path: /instance_groups/name=${ig}/vm_type
35
+ value: ${vm_type}
36
+
37
+ YAML
38
+ done
@@ -0,0 +1,3 @@
1
+ - type: replace
2
+ path: /instance_groups/name=<%= project_name %>/networks/name=default/name
3
+ value: ((network_name))
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Gen
3
- VERSION = "0.96.0"
3
+ VERSION = "0.97.0"
4
4
  end
5
5
  end
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.96.0
4
+ version: 0.97.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: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2017-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -177,8 +177,6 @@ files:
177
177
  - lib/bosh/gen/generators/errand_generator/templates/jobs/%job_name%/monit.tt
178
178
  - lib/bosh/gen/generators/errand_generator/templates/jobs/%job_name%/templates/bin/run.tt
179
179
  - lib/bosh/gen/generators/errand_generator/templates/jobs/%job_name%/templates/config/.gitkeep
180
- - lib/bosh/gen/generators/errand_generator/templates/jobs/%job_name%/templates/helpers/ctl_setup.sh
181
- - lib/bosh/gen/generators/errand_generator/templates/jobs/%job_name%/templates/helpers/ctl_utils.sh
182
180
  - lib/bosh/gen/generators/extract_job_generator.rb
183
181
  - lib/bosh/gen/generators/extract_package_generator.rb
184
182
  - lib/bosh/gen/generators/job_generator.rb
@@ -197,13 +195,14 @@ files:
197
195
  - lib/bosh/gen/generators/new_release_generator.rb
198
196
  - lib/bosh/gen/generators/new_release_generator/templates/LICENSE.md.tt
199
197
  - lib/bosh/gen/generators/new_release_generator/templates/README.md.tt
200
- - lib/bosh/gen/generators/new_release_generator/templates/Rakefile
201
198
  - lib/bosh/gen/generators/new_release_generator/templates/blobs/.gitkeep
202
199
  - lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name%/monit.tt
203
200
  - lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name%/spec.tt
204
201
  - lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name%/templates/ignoreme
205
202
  - lib/bosh/gen/generators/new_release_generator/templates/manifests/%project_name%.yml.tt
206
203
  - lib/bosh/gen/generators/new_release_generator/templates/manifests/operators/dev.yml.tt
204
+ - lib/bosh/gen/generators/new_release_generator/templates/manifests/operators/pick-from-cloud-config.sh.tt
205
+ - lib/bosh/gen/generators/new_release_generator/templates/manifests/operators/use-network.yml.tt
207
206
  - lib/bosh/gen/generators/new_release_generator/templates/packages/.gitkeep
208
207
  - lib/bosh/gen/generators/new_release_generator/templates/src/.gitkeep
209
208
  - lib/bosh/gen/generators/package_apt_generator.rb
@@ -245,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
244
  version: '0'
246
245
  requirements: []
247
246
  rubyforge_project:
248
- rubygems_version: 2.6.13
247
+ rubygems_version: 2.6.14
249
248
  signing_key:
250
249
  specification_version: 4
251
250
  summary: ''
@@ -1,64 +0,0 @@
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=${2:-${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
-
24
- # Setup the PATH and LD_LIBRARY_PATH
25
- export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-''} # default to empty
26
- for package_dir in $(ls -d /var/vcap/packages/*)
27
- do
28
- has_busybox=0
29
- # Add all packages' /bin & /sbin into $PATH
30
- for package_bin_dir in $(ls -d ${package_dir}/*bin)
31
- do
32
- # Do not add any packages that use busybox, as impacts builtin commands and
33
- # is often used for different architecture (via containers)
34
- if [ -f ${package_bin_dir}/busybox ]
35
- then
36
- has_busybox=1
37
- else
38
- export PATH=${package_bin_dir}:$PATH
39
- fi
40
- done
41
- if [ "$has_busybox" == "0" ] && [ -d ${package_dir}/lib ]
42
- then
43
- export LD_LIBRARY_PATH=${package_dir}/lib:$LD_LIBRARY_PATH
44
- fi
45
- done
46
-
47
- # Setup log, run and tmp folders
48
-
49
- export RUN_DIR=/var/vcap/sys/run/$JOB_NAME
50
- export LOG_DIR=/var/vcap/sys/log/$JOB_NAME
51
- export TMP_DIR=/var/vcap/sys/tmp/$JOB_NAME
52
- export STORE_DIR=/var/vcap/store/$JOB_NAME
53
- for dir in $RUN_DIR $LOG_DIR $TMP_DIR $STORE_DIR
54
- do
55
- mkdir -p ${dir}
56
- chown vcap:vcap ${dir}
57
- chmod 775 ${dir}
58
- done
59
- export TMPDIR=$TMP_DIR
60
-
61
- export C_INCLUDE_PATH=/var/vcap/packages/mysqlclient/include/mysql:/var/vcap/packages/sqlite/include:/var/vcap/packages/libpq/include
62
- export LIBRARY_PATH=/var/vcap/packages/mysqlclient/lib/mysql:/var/vcap/packages/sqlite/lib:/var/vcap/packages/libpq/lib
63
-
64
- echo '$PATH' $PATH
@@ -1,155 +0,0 @@
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 2>&1
42
- }
43
-
44
- pid_guard() {
45
- pidfile=$1
46
- name=$2
47
-
48
- if [ -f "$pidfile" ]; then
49
- pid=$(head -1 "$pidfile")
50
-
51
- if [ -n "$pid" ] && [ -e /proc/$pid ]; then
52
- echo "$name is already running, please stop it first"
53
- exit 1
54
- fi
55
-
56
- echo "Removing stale pidfile..."
57
- rm $pidfile
58
- fi
59
- }
60
-
61
- wait_pid() {
62
- pid=$1
63
- try_kill=$2
64
- timeout=${3:-0}
65
- force=${4:-0}
66
- countdown=$(( $timeout * 10 ))
67
-
68
- echo wait_pid $pid $try_kill $timeout $force $countdown
69
- if [ -e /proc/$pid ]; then
70
- if [ "$try_kill" = "1" ]; then
71
- echo "Killing $pidfile: $pid "
72
- kill $pid
73
- fi
74
- while [ -e /proc/$pid ]; do
75
- sleep 0.1
76
- [ "$countdown" != '0' -a $(( $countdown % 10 )) = '0' ] && echo -n .
77
- if [ $timeout -gt 0 ]; then
78
- if [ $countdown -eq 0 ]; then
79
- if [ "$force" = "1" ]; then
80
- echo -ne "\nKill timed out, using kill -9 on $pid... "
81
- kill -9 $pid
82
- sleep 0.5
83
- fi
84
- break
85
- else
86
- countdown=$(( $countdown - 1 ))
87
- fi
88
- fi
89
- done
90
- if [ -e /proc/$pid ]; then
91
- echo "Timed Out"
92
- else
93
- echo "Stopped"
94
- fi
95
- else
96
- echo "Process $pid is not running"
97
- echo "Attempting to kill pid anyway..."
98
- kill $pid
99
- fi
100
- }
101
-
102
- wait_pidfile() {
103
- pidfile=$1
104
- try_kill=$2
105
- timeout=${3:-0}
106
- force=${4:-0}
107
- countdown=$(( $timeout * 10 ))
108
-
109
- if [ -f "$pidfile" ]; then
110
- pid=$(head -1 "$pidfile")
111
- if [ -z "$pid" ]; then
112
- echo "Unable to get pid from $pidfile"
113
- exit 1
114
- fi
115
-
116
- wait_pid $pid $try_kill $timeout $force
117
-
118
- rm -f $pidfile
119
- else
120
- echo "Pidfile $pidfile doesn't exist"
121
- fi
122
- }
123
-
124
- kill_and_wait() {
125
- pidfile=$1
126
- # Monit default timeout for start/stop is 30s
127
- # Append 'with timeout {n} seconds' to monit start/stop program configs
128
- timeout=${2:-25}
129
- force=${3:-1}
130
- if [[ -f ${pidfile} ]]
131
- then
132
- wait_pidfile $pidfile 1 $timeout $force
133
- else
134
- # TODO assume $1 is something to grep from 'ps ax'
135
- pid="$(ps auwwx | grep "$1" | awk '{print $2}')"
136
- wait_pid $pid 1 $timeout $force
137
- fi
138
- }
139
-
140
- check_nfs_mount() {
141
- opts=$1
142
- exports=$2
143
- mount_point=$3
144
-
145
- if grep -qs $mount_point /proc/mounts; then
146
- echo "Found NFS mount $mount_point"
147
- else
148
- echo "Mounting NFS..."
149
- mount $opts $exports $mount_point
150
- if [ $? != 0 ]; then
151
- echo "Cannot mount NFS from $exports to $mount_point, exiting..."
152
- exit 1
153
- fi
154
- fi
155
- }
@@ -1,15 +0,0 @@
1
- desc "Generates a properties file for each job based on properties.X.Y used in templates"
2
- task :job_properties do
3
- require "fileutils"
4
- Dir["jobs/*"].each do |path|
5
- puts "Searching job #{File.basename(path)}..."
6
- FileUtils.chdir(path) do
7
- properties = []
8
- Dir["templates/*.erb"].each do |template_path|
9
- properties |= File.read(template_path).scan(/\bproperties\.[\w\.]*\b/)
10
- puts properties.join("\n")
11
- File.open("properties", "w") { |file| file << properties.join("\n") }
12
- end
13
- end
14
- end
15
- end