concourse-deployer 0.2.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/concourse/deployer.rb +42 -41
- data/lib/concourse/deployer/utils.rb +22 -31
- data/lib/concourse/deployer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9961c750811bf5c2b0be8ccb7903655c1597f00ad643c74b2a2b470a03cb2afc
|
4
|
+
data.tar.gz: 8e32bdeb837566cbc5478cc4c7c9464cd8edd1b6c68297e151828afe6c3df707
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8bb2e00967f3c3cbd284f35f34e6b59855c795916a6b85d581a42aca0448f494035bc5abb660e7edb7d11a251cc1de2212dc219fa32019e3c4afced43fb0563
|
7
|
+
data.tar.gz: 7457cb3e89f63f9b53b2afcbb98e08a70e7a7c936f98e86b0bb0acc76d9906249e9cc275ee0a36da4168b3185f4cad1f2f0fbace987a735a91971aac31663764
|
data/CHANGELOG.md
CHANGED
data/lib/concourse/deployer.rb
CHANGED
@@ -12,16 +12,16 @@ module Concourse
|
|
12
12
|
include Rake::DSL
|
13
13
|
include Concourse::Deployer::Utils
|
14
14
|
|
15
|
-
GCP_SERVICE_ACCOUNT_FILE
|
16
|
-
ENVRC_FILE
|
15
|
+
GCP_SERVICE_ACCOUNT_FILE = "service-account.key.json"
|
16
|
+
ENVRC_FILE = ".envrc"
|
17
17
|
|
18
|
-
BBL_STATE_FILE
|
19
|
-
BBL_VARS_DIR
|
18
|
+
BBL_STATE_FILE = "bbl-state.json"
|
19
|
+
BBL_VARS_DIR = "vars"
|
20
20
|
|
21
|
-
BOSH_DEPLOYMENT
|
22
|
-
BOSH_SECRETS
|
23
|
-
BOSH_VARS_STORE
|
24
|
-
BOSH_OPERATIONS
|
21
|
+
BOSH_DEPLOYMENT = "concourse"
|
22
|
+
BOSH_SECRETS = "secrets.yml"
|
23
|
+
BOSH_VARS_STORE = "cluster-creds.yml"
|
24
|
+
BOSH_OPERATIONS = "operations.yml"
|
25
25
|
|
26
26
|
CONCOURSE_DEPLOYMENT_VARS = "deployment-vars.yml"
|
27
27
|
|
@@ -35,10 +35,10 @@ module Concourse
|
|
35
35
|
return true unless File.exist?(GCP_SERVICE_ACCOUNT_FILE)
|
36
36
|
|
37
37
|
overwrite = prompt "A #{GCP_SERVICE_ACCOUNT_FILE} file already exists. Do you want to overwrite it? (y/n)", "n"
|
38
|
-
return !!
|
38
|
+
return !!(overwrite =~ /^y/i)
|
39
39
|
end
|
40
40
|
|
41
|
-
def bbl_gcp_init
|
41
|
+
def bbl_gcp_init(project_id)
|
42
42
|
bbl_init
|
43
43
|
unless_which "gcloud", "https://cloud.google.com/sdk/downloads"
|
44
44
|
ensure_in_gitcrypt GCP_SERVICE_ACCOUNT_FILE
|
@@ -57,7 +57,7 @@ module Concourse
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def bbl_gcp_up
|
60
|
-
unless ENV[
|
60
|
+
unless ENV["BBL_GCP_PROJECT_ID"]
|
61
61
|
error "Environment variable BBL_GCP_PROJECT_ID is not set. Did you run `rake bbl:gcp:init` and `direnv allow`?"
|
62
62
|
end
|
63
63
|
|
@@ -97,7 +97,7 @@ module Concourse
|
|
97
97
|
|
98
98
|
v["postgres_client_cert"] = (v["postgres_client_cert"] || {}).tap do |cert|
|
99
99
|
cert["certificate"] ||= prompt_for_file_contents "Path to client-cert.pem"
|
100
|
-
cert["private_key"] ||= prompt_for_file_contents "Path to client-key.pem"
|
100
|
+
cert["private_key"] ||= prompt_for_file_contents "Path to client-key.pem"
|
101
101
|
end
|
102
102
|
v["postgres_ca_cert"] = (v["postgres_ca_cert"] || {}).tap do |cert|
|
103
103
|
cert["certificate"] ||= prompt_for_file_contents "Path to server-ca.pem"
|
@@ -129,8 +129,9 @@ module Concourse
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
def bosh_update_concourse_deployment
|
133
|
-
|
132
|
+
def bosh_update_concourse_deployment(branch_or_tag)
|
133
|
+
branch_or_tag ||= "master"
|
134
|
+
ensure_git_submodule "https://github.com/concourse/concourse-bosh-deployment", branch_or_tag
|
134
135
|
end
|
135
136
|
|
136
137
|
def bosh_update_ubuntu_stemcell
|
@@ -155,7 +156,7 @@ module Concourse
|
|
155
156
|
# bosh_update_release "cloudfoundry-incubator/windows-utilities-release"
|
156
157
|
# end
|
157
158
|
|
158
|
-
def bosh_deploy
|
159
|
+
def bosh_deploy(command: "deploy")
|
159
160
|
unless File.exists?(BOSH_SECRETS)
|
160
161
|
error "File #{BOSH_SECRETS} does not exist. Please run `rake bosh:init` first."
|
161
162
|
end
|
@@ -167,7 +168,7 @@ module Concourse
|
|
167
168
|
ensure_in_gitcrypt BOSH_SECRETS
|
168
169
|
ensure_in_gitcrypt BOSH_VARS_STORE
|
169
170
|
|
170
|
-
external_dns_name = bosh_secrets[
|
171
|
+
external_dns_name = bosh_secrets["external_dns_name"]
|
171
172
|
external_url = "https://#{external_dns_name}"
|
172
173
|
|
173
174
|
ops_files = Dir[File.join(File.dirname(__FILE__), "deployer", "operations", "*.yml")]
|
@@ -212,15 +213,15 @@ module Concourse
|
|
212
213
|
tempfile_key = Tempfile.new
|
213
214
|
tempfile_ca = Tempfile.new
|
214
215
|
begin
|
215
|
-
tempfile_cert.write bosh_secrets[
|
216
|
-
tempfile_key.write bosh_secrets[
|
217
|
-
tempfile_ca.write bosh_secrets[
|
216
|
+
tempfile_cert.write bosh_secrets["postgres_client_cert"]["certificate"]
|
217
|
+
tempfile_key.write bosh_secrets["postgres_client_cert"]["private_key"]
|
218
|
+
tempfile_ca.write bosh_secrets["postgres_ca_cert"]["certificate"]
|
218
219
|
|
219
220
|
tempfile_cert.close
|
220
221
|
tempfile_key.close
|
221
222
|
tempfile_ca.close
|
222
223
|
|
223
|
-
command = %Q{psql "sslmode=verify-ca sslrootcert=#{tempfile_ca.path} sslcert=#{tempfile_cert.path} sslkey=#{tempfile_key.path} hostaddr=#{bosh_secrets[
|
224
|
+
command = %Q{psql "sslmode=verify-ca sslrootcert=#{tempfile_ca.path} sslcert=#{tempfile_cert.path} sslkey=#{tempfile_key.path} hostaddr=#{bosh_secrets["postgres_host"]} user=#{bosh_secrets["postgres_role"]} dbname=atc"}
|
224
225
|
|
225
226
|
sh command
|
226
227
|
ensure
|
@@ -263,8 +264,8 @@ module Concourse
|
|
263
264
|
|
264
265
|
namespace "update" do
|
265
266
|
desc "update the git submodule for concourse-bosh-deployment"
|
266
|
-
task "concourse_deployment" do
|
267
|
-
bosh_update_concourse_deployment
|
267
|
+
task "concourse_deployment", ["branch_or_tag"] do |t, args|
|
268
|
+
bosh_update_concourse_deployment args["branch_or_tag"]
|
268
269
|
end
|
269
270
|
|
270
271
|
desc "upload ubuntu stemcell to the director"
|
@@ -272,25 +273,25 @@ module Concourse
|
|
272
273
|
bosh_update_ubuntu_stemcell
|
273
274
|
end
|
274
275
|
|
275
|
-
# desc "upload windows stemcell to the director"
|
276
|
-
# task "windows_stemcell" do
|
277
|
-
# bosh_update_windows_stemcell
|
278
|
-
# end
|
279
|
-
|
280
|
-
# desc "upload concourse windows release to the director"
|
281
|
-
# task "concourse_windows_release" do
|
282
|
-
# bosh_update_concourse_windows_release
|
283
|
-
# end
|
284
|
-
|
285
|
-
# desc "upload windows-ruby-dev-tools release to the director"
|
286
|
-
# task "windows_ruby_dev_tools" do
|
287
|
-
# bosh_update_windows_ruby_dev_tools
|
288
|
-
# end
|
289
|
-
|
290
|
-
# desc "upload windows-utilities release to the director"
|
291
|
-
# task "windows_utilities_release" do
|
292
|
-
# bosh_update_windows_utilities_release
|
293
|
-
# end
|
276
|
+
# desc "upload windows stemcell to the director"
|
277
|
+
# task "windows_stemcell" do
|
278
|
+
# bosh_update_windows_stemcell
|
279
|
+
# end
|
280
|
+
|
281
|
+
# desc "upload concourse windows release to the director"
|
282
|
+
# task "concourse_windows_release" do
|
283
|
+
# bosh_update_concourse_windows_release
|
284
|
+
# end
|
285
|
+
|
286
|
+
# desc "upload windows-ruby-dev-tools release to the director"
|
287
|
+
# task "windows_ruby_dev_tools" do
|
288
|
+
# bosh_update_windows_ruby_dev_tools
|
289
|
+
# end
|
290
|
+
|
291
|
+
# desc "upload windows-utilities release to the director"
|
292
|
+
# task "windows_utilities_release" do
|
293
|
+
# bosh_update_windows_utilities_release
|
294
|
+
# end
|
294
295
|
end
|
295
296
|
|
296
297
|
desc "deploy concourse"
|
@@ -1,43 +1,43 @@
|
|
1
|
-
require
|
1
|
+
require "term/ansicolor"
|
2
2
|
|
3
3
|
module Concourse
|
4
4
|
class Deployer
|
5
5
|
module Utils
|
6
6
|
include Term::ANSIColor
|
7
7
|
|
8
|
-
GITIGNORE_FILE
|
9
|
-
GITATTRIBUTES_FILE
|
8
|
+
GITIGNORE_FILE = ".gitignore"
|
9
|
+
GITATTRIBUTES_FILE = ".gitattributes"
|
10
10
|
|
11
|
-
def sh
|
11
|
+
def sh(command)
|
12
12
|
running "(in #{Dir.pwd}) #{command}"
|
13
13
|
super command, verbose: false
|
14
14
|
end
|
15
15
|
|
16
|
-
def running
|
16
|
+
def running(message)
|
17
17
|
print bold, red, "RUNNING: ", reset, message, "\n"
|
18
18
|
end
|
19
19
|
|
20
|
-
def note
|
20
|
+
def note(message)
|
21
21
|
print bold, green, "NOTE: ", reset, message, "\n"
|
22
22
|
end
|
23
23
|
|
24
|
-
def important
|
24
|
+
def important(message)
|
25
25
|
print bold, "NOTE: ", message, reset, "\n"
|
26
26
|
end
|
27
27
|
|
28
|
-
def error
|
28
|
+
def error(message, continue = false)
|
29
29
|
print red, bold, "ERROR: #{message}", reset, "\n"
|
30
30
|
exit 1 unless continue
|
31
31
|
end
|
32
32
|
|
33
|
-
def ensure_file
|
33
|
+
def ensure_file(filename, &block)
|
34
34
|
return if File.exist?(filename)
|
35
35
|
File.open(filename, "w") do |f|
|
36
36
|
block.call f
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def ensure_in_gitignore
|
40
|
+
def ensure_in_gitignore(file_glob)
|
41
41
|
if File.exist?(GITIGNORE_FILE)
|
42
42
|
if File.read(GITIGNORE_FILE).split("\n").include?(file_glob)
|
43
43
|
note "found '#{file_glob}' already present in #{GITIGNORE_FILE}"
|
@@ -48,7 +48,7 @@ module Concourse
|
|
48
48
|
File.open(GITIGNORE_FILE, "a") { |f| f.puts file_glob }
|
49
49
|
end
|
50
50
|
|
51
|
-
def ensure_in_gitcrypt
|
51
|
+
def ensure_in_gitcrypt(file_glob)
|
52
52
|
crypt_entry = "#{file_glob} filter=git-crypt diff=git-crypt"
|
53
53
|
if File.exist?(GITATTRIBUTES_FILE)
|
54
54
|
if File.read(GITATTRIBUTES_FILE).split("\n").include?(crypt_entry)
|
@@ -60,7 +60,7 @@ module Concourse
|
|
60
60
|
File.open(GITATTRIBUTES_FILE, "a") { |f| f.puts crypt_entry }
|
61
61
|
end
|
62
62
|
|
63
|
-
def ensure_in_envrc
|
63
|
+
def ensure_in_envrc(entry_key, entry_value = nil)
|
64
64
|
entries = if File.exist?(ENVRC_FILE)
|
65
65
|
File.read(ENVRC_FILE).split("\n")
|
66
66
|
else
|
@@ -108,30 +108,21 @@ module Concourse
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
def ensure_git_submodule
|
111
|
+
def ensure_git_submodule(repo_url, commitish)
|
112
112
|
repo_name = File.basename repo_url
|
113
113
|
sh "git submodule add '#{repo_url}'" unless Dir.exists?(repo_name)
|
114
|
-
Dir.chdir(repo_name) do
|
115
|
-
sh "git checkout '#{commitish}'"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def update_git_submodule repo_url, commitish
|
120
|
-
ensure_git_submodule repo_url, commitish
|
121
|
-
|
122
|
-
repo_name = File.basename repo_url
|
123
114
|
Dir.chdir(repo_name) do
|
124
115
|
sh "git remote update"
|
125
|
-
sh "git
|
116
|
+
sh "git checkout '#{commitish}'"
|
126
117
|
end
|
127
118
|
end
|
128
119
|
|
129
|
-
def which
|
120
|
+
def which(command)
|
130
121
|
found = `which #{command}`
|
131
122
|
return $?.success? ? found : nil
|
132
123
|
end
|
133
124
|
|
134
|
-
def unless_which
|
125
|
+
def unless_which(command, whereto)
|
135
126
|
if which command
|
136
127
|
note "found command '#{command}'"
|
137
128
|
return
|
@@ -139,7 +130,7 @@ module Concourse
|
|
139
130
|
error "please install '#{command}' by visiting #{whereto}"
|
140
131
|
end
|
141
132
|
|
142
|
-
def prompt
|
133
|
+
def prompt(query, default = nil)
|
143
134
|
loop do
|
144
135
|
message = query
|
145
136
|
message += " [#{default}]" if default
|
@@ -155,7 +146,7 @@ module Concourse
|
|
155
146
|
end
|
156
147
|
end
|
157
148
|
|
158
|
-
def prompt_for_file_contents
|
149
|
+
def prompt_for_file_contents(query)
|
159
150
|
loop do
|
160
151
|
path = prompt query
|
161
152
|
return File.read(path) if File.exists?(path)
|
@@ -167,7 +158,7 @@ module Concourse
|
|
167
158
|
`bbl lbs`.split(":").last.strip
|
168
159
|
end
|
169
160
|
|
170
|
-
def bosh_secrets
|
161
|
+
def bosh_secrets(&block)
|
171
162
|
vars = File.exists?(BOSH_SECRETS) ? YAML.load_file(BOSH_SECRETS) : {}
|
172
163
|
return vars unless block_given?
|
173
164
|
|
@@ -176,7 +167,7 @@ module Concourse
|
|
176
167
|
vars
|
177
168
|
end
|
178
169
|
|
179
|
-
def bosh_update_stemcell
|
170
|
+
def bosh_update_stemcell(name)
|
180
171
|
doc = Nokogiri::XML(open("https://bosh.io/stemcells/#{name}"))
|
181
172
|
url = doc.at_xpath("//a[contains(text(), 'Light Stemcell')]/@href")
|
182
173
|
if url.nil?
|
@@ -185,7 +176,7 @@ module Concourse
|
|
185
176
|
sh "bosh upload-stemcell #{url}"
|
186
177
|
end
|
187
178
|
|
188
|
-
def bosh_update_release
|
179
|
+
def bosh_update_release(repo)
|
189
180
|
doc = Nokogiri::XML(open("https://bosh.io/releases/github.com/#{repo}?all=1"))
|
190
181
|
url = doc.at_xpath("//a[contains(text(), 'Release Tarball')]/@href")
|
191
182
|
if url.nil?
|
@@ -197,7 +188,7 @@ module Concourse
|
|
197
188
|
sh "bosh upload-release #{url}"
|
198
189
|
end
|
199
190
|
|
200
|
-
def bosh_update_from_git_repo
|
191
|
+
def bosh_update_from_git_repo(git)
|
201
192
|
dirname = File.basename(git)
|
202
193
|
Dir.mktmpdir do |dir|
|
203
194
|
Dir.chdir dir do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: concourse-deployer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Dalessio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|