concourse-deployer 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: e35d5f547ba50ab86ab55fa4e7767cf17ac17e051e7fc2908f192e5633528da2
4
- data.tar.gz: bfd4742437ff9911aca9b9d7302a3df8ebb3c2e8cf83651120ad779da8ac2c7d
3
+ metadata.gz: 25c2a4453ab7efcd1e0866deea1dff9ff2a343c7977e0ac62496409eeb8cf99e
4
+ data.tar.gz: d8400270b0a80d7238ecd774596c451cd6b4e8f0f88e5ad44f7f6f36eb2c5329
5
5
  SHA512:
6
- metadata.gz: ff1ce32001402f065b54fe410a0f690b729a6d1a4e5ca1a73065c7daadbde7e913c040b462556b1481407781d10aeb3986d342276e623327dce915cf645713db
7
- data.tar.gz: 24a6f65a6bd1d0facd44948f89a88c5df47b3969ab6f36e68e897883334b5e18dc48739acf8591e73a3b5711e85348c1b871b5fd811e83c5a1982a0d197548c0
6
+ metadata.gz: a2c7aa9c926366bca72b17d43184ca815cd4cfd23e642a7f87c033e61a4ba116d0d9647853713b45471944c3b09d2d156775f92ab61c1d4a2d55db4d3541aaa3
7
+ data.tar.gz: cd7b31dce5e2c977d503c4b36cba068536b622b618993ca26fd5b791b7848de298da05b342cd4134d12c42e3a6627b127ee8dfa77fecd15a43dfc207fa6ad547
@@ -1,5 +1,15 @@
1
1
  # Changelog for `concourse-deployer`
2
2
 
3
+ ## v0.2.0 / 2019-02-10
4
+
5
+ Features:
6
+
7
+ - Use Caddy (via caddy-bosh-release) for managing LetsEncrypt certificates.
8
+ - `scale-vars.yml` is now `deployment-vars.yml` and presents additional customizable variables.
9
+ - New task `db:connect` for getting a postgres commandline prompt.
10
+ - New task `bosh:interpolate` for examining the final BOSH manifest
11
+
12
+
3
13
  ## v0.1.0 / 2019-01-04
4
14
 
5
15
  First release.
data/README.md CHANGED
@@ -4,7 +4,7 @@ Provides easy installation and maintenance of an opinionated [Concourse](https:/
4
4
 
5
5
  - external Postgres database
6
6
  - Github auth integration
7
- - LetsEncrypt integration for SSL cert management
7
+ - LetsEncrypt integration, via [caddy](https://caddyserver.com/) and [caddy-bosh-release](https://github.com/dpb587/caddy-bosh-release)
8
8
  - Windows™ workers
9
9
 
10
10
  Today this only supports deployment to GCP.
@@ -22,12 +22,8 @@ rake bosh:update
22
22
  rake bosh:deploy
23
23
  ```
24
24
 
25
- You can create and deploy a LetsEncrypt SSL cert:
25
+ During `bbl:gcp:init` and `bosh:init` you'll be prompted interactively for any necessary information. Note that you need a DNS domain name in order for Caddy to create and manage your SSL certs.
26
26
 
27
- ``` sh
28
- rake letsencrypt:create letsencrypt:backup letsencrypt:import
29
- rake bosh:deploy
30
- ```
31
27
 
32
28
  ## Requirements
33
29
 
@@ -65,17 +61,15 @@ Concourse::Deployer.new.create_tasks!
65
61
  Available tasks:
66
62
 
67
63
  ``` sh
68
- rake bbl:gcp:init[gcp_project_id] # initialize bosh-bootloader for GCP
69
- rake bbl:gcp:up # terraform your environment and deploy the bosh director
70
- rake bosh:deploy # deploy concourse
71
- rake bosh:init # prepare the concourse bosh deployment
72
- rake bosh:update # upload stemcells and releases to the director
73
- rake bosh:update:ubuntu_stemcell # upload ubuntu stemcell to the director
74
- rake letsencrypt:backup # backup web:/etc/letsencrypt to local disk
75
- rake letsencrypt:create # create a cert
76
- rake letsencrypt:import # import letsencrypt keys into `secrets.yml` from backup
77
- rake letsencrypt:renew # renew the certificate
78
- rake letsencrypt:restore # restore web:/etc/letsencrypt from backup
64
+ rake bbl:gcp:init[gcp_project_id] # initialize bosh-bootloader for GCP
65
+ rake bbl:gcp:up # terraform your environment and deploy the bosh director
66
+ rake bosh:deploy # deploy concourse
67
+ rake bosh:init # prepare the concourse bosh deployment
68
+ rake bosh:interpolate # view interpolated manifest
69
+ rake bosh:update # macro task for all `update` subtasks
70
+ rake bosh:update:concourse_deployment # update the git submodule for concourse-bosh-deployment
71
+ rake bosh:update:ubuntu_stemcell # upload ubuntu stemcell to the director
72
+ rake db:connect # connect to the postgres database
79
73
  ```
80
74
 
81
75
  See full instructions below.
@@ -92,7 +86,6 @@ Files which contain sensitive data:
92
86
  * `secrets.yml`
93
87
  * `cluster-creds.yml`
94
88
  * the `vars` subdirectory
95
- * `letsencrypt.tar.gz` (if you're using the letsencrypt SSL cert functionality)
96
89
 
97
90
  You will see these files listed in `.gitattributes` invoking git-crypt for them.
98
91
 
@@ -212,33 +205,40 @@ __NOTE:__ This task is idempotent! Yay Bosh.
212
205
 
213
206
  ### Scale your Concourse deployment
214
207
 
215
- Your first deployment will spin up one (1) web VM, and two (2) Linux worker VMs. But you can scale these numbers up as needed by editing the file `scale-vars.yml`, whose default contents looks like:
208
+ Your first deployment will spin up one (1) web VM, and two (2) Linux worker VMs. But you can scale these numbers up as needed by editing the file `deployment-vars.yml`, whose default contents include the values:
216
209
 
217
210
  ```yaml
218
211
  ---
219
212
  web_instances: 1
220
213
  worker_instances: 2
214
+ web_vm_type: default
215
+ worker_vm_type: default
216
+ worker_ephemeral_disk: 50GB_ephemeral_disk
221
217
  ```
222
218
 
223
219
  Edit this file as appropriate for your needs, and re-run `rake bosh:deploy`.
224
220
 
225
221
 
226
- ### Manage your letsencrypt SSL cert
222
+ ### Custom bosh ops files
223
+
224
+ If you want to perform any custom operations on the manifest, put them in a file named `operations.yml` and they'll be pulled in as the __final__ ops file during deployment.
225
+
226
+
227
+ ### Connect to the database
228
+
229
+ If you ever need to connect to the database, here's how:
227
230
 
228
231
  ``` sh
229
- $ rake letsencrypt:backup
230
- $ rake letsencrypt:create
231
- $ rake letsencrypt:restore
232
- $ rake letsencrypt:import
233
- $ rake letsencrypt:renew
232
+ rake db:connect
234
233
  ```
235
234
 
236
- __NOTE:__ These tasks will create and use `letsencrypt.tar.gz` which contains sensitive data.
237
-
235
+ This will:
238
236
 
239
- ### Custom bosh ops files
237
+ * securely write your SSL cert, key, and CA cert to disk
238
+ * run `psql` and connect to the database
239
+ * clean up the cert and key files
240
240
 
241
- If you want to perform any custom operations on the manifest, put them in a file named `operations.yml` and they'll be pulled in as the __final__ ops file during deployment.
241
+ Note that you will need to type in your database password; this is located in `secrets.yml`.
242
242
 
243
243
 
244
244
  ## Upgrading `bbl`
@@ -286,8 +286,8 @@ The gem is available as open source under the terms of the [MIT License](http://
286
286
  - [x] + x_frame_options: "SAMEORIGIN"
287
287
  - [x] + container_placement_strategy: random
288
288
  - [ ] enable encryption https://concourse.ci/encryption.html
289
- - [ ] allow scaling up/down by locally setting number of VMs (currently hardcoded in gem)
290
- - [ ] start using https://github.com/dpb587/caddy-bosh-release instead of the letsencrypt rake tasks
289
+ - [x] allow scaling up/down by locally setting number of VMs (currently hardcoded in gem)
290
+ - [x] start using https://github.com/dpb587/caddy-bosh-release instead of the letsencrypt rake tasks
291
291
 
292
292
 
293
293
  Things to follow up on:
@@ -5,26 +5,25 @@ require "open-uri"
5
5
  require "nokogiri"
6
6
  require "yaml"
7
7
  require "rake"
8
+ require "tempfile"
8
9
 
9
10
  module Concourse
10
11
  class Deployer
11
12
  include Rake::DSL
12
13
  include Concourse::Deployer::Utils
13
14
 
14
- GCP_SERVICE_ACCOUNT_FILE = "service-account.key.json"
15
- ENVRC_FILE = ".envrc"
15
+ GCP_SERVICE_ACCOUNT_FILE = "service-account.key.json"
16
+ ENVRC_FILE = ".envrc"
16
17
 
17
- BBL_STATE_FILE = "bbl-state.json"
18
- BBL_VARS_DIR = "vars"
18
+ BBL_STATE_FILE = "bbl-state.json"
19
+ BBL_VARS_DIR = "vars"
19
20
 
20
- BOSH_DEPLOYMENT = "concourse"
21
- BOSH_SECRETS = "secrets.yml"
22
- BOSH_VARS_STORE = "cluster-creds.yml"
23
- BOSH_OPERATIONS = "operations.yml"
21
+ BOSH_DEPLOYMENT = "concourse"
22
+ BOSH_SECRETS = "secrets.yml"
23
+ BOSH_VARS_STORE = "cluster-creds.yml"
24
+ BOSH_OPERATIONS = "operations.yml"
24
25
 
25
- CONCOURSE_SCALE_VARS = "scale-vars.yml"
26
-
27
- LETSENCRYPT_BACKUP_FILE = "letsencrypt.tar.gz"
26
+ CONCOURSE_DEPLOYMENT_VARS = "deployment-vars.yml"
28
27
 
29
28
  def bbl_init
30
29
  unless_which "bbl", "https://github.com/cloudfoundry/bosh-bootloader/releases"
@@ -118,6 +117,16 @@ module Concourse
118
117
  end
119
118
  end
120
119
  end
120
+
121
+ ensure_file CONCOURSE_DEPLOYMENT_VARS do |f|
122
+ f.write({
123
+ "web_instances" => 1,
124
+ "worker_instances" => 2, # 1
125
+ "web_vm_type" => "default",
126
+ "worker_vm_type" => "default", # "n1-standard-2"
127
+ "worker_ephemeral_disk" => "50GB_ephemeral_disk",
128
+ }.to_yaml)
129
+ end
121
130
  end
122
131
 
123
132
  def bosh_update_concourse_deployment
@@ -146,33 +155,31 @@ module Concourse
146
155
  # bosh_update_release "cloudfoundry-incubator/windows-utilities-release"
147
156
  # end
148
157
 
149
- def bosh_deploy
158
+ def bosh_deploy command: "deploy"
150
159
  unless File.exists?(BOSH_SECRETS)
151
160
  error "File #{BOSH_SECRETS} does not exist. Please run `rake bosh:init` first."
152
161
  end
153
162
 
163
+ unless File.exists?(CONCOURSE_DEPLOYMENT_VARS)
164
+ error "File #{CONCOURSE_DEPLOYMENT_VARS} does not exist. Please run `rake bosh:init` first."
165
+ end
166
+
154
167
  ensure_in_gitcrypt BOSH_SECRETS
155
168
  ensure_in_gitcrypt BOSH_VARS_STORE
156
169
 
157
- ensure_file CONCOURSE_SCALE_VARS do |f|
158
- f.write({"web_instances" => 1, "worker_instances" => 2}.to_yaml)
159
- end
160
-
161
170
  external_dns_name = bosh_secrets['external_dns_name']
162
171
  external_url = "https://#{external_dns_name}"
163
172
 
173
+ ops_files = Dir[File.join(File.dirname(__FILE__), "deployer", "operations", "*.yml")]
174
+
164
175
  # command will be run in the bosh deployment submodule's cluster directory
165
176
  command = [].tap do |c|
166
- c << "bosh deploy concourse.yml"
177
+ c << "bosh #{command} concourse.yml"
167
178
  # c << "--no-redact" # DEBUG
168
179
  c << "-l ../versions.yml"
169
180
  c << "-l ../../#{BOSH_SECRETS}"
170
181
  c << "--vars-store ../../#{BOSH_VARS_STORE}"
171
182
  c << "-o operations/basic-auth.yml"
172
- c << "-o operations/privileged-http.yml"
173
- c << "-o operations/privileged-https.yml"
174
- c << "-o operations/tls.yml"
175
- c << "-o operations/tls-vars.yml"
176
183
  c << "-o operations/web-network-extension.yml"
177
184
  c << "-o operations/external-postgres.yml"
178
185
  c << "-o operations/external-postgres-tls.yml"
@@ -186,13 +193,13 @@ module Concourse
186
193
  c << "--var network_name=default"
187
194
  c << "--var external_host='#{external_dns_name}'"
188
195
  c << "--var external_url='#{external_url}'"
189
- c << "--var web_vm_type=default"
190
- c << "--var worker_vm_type=default"
191
- c << "--var worker_ephemeral_disk=50GB_ephemeral_disk"
192
196
  c << "--var deployment_name=#{BOSH_DEPLOYMENT}"
193
197
  c << "--var web_network_name=private"
194
198
  c << "--var web_network_vm_extension=lb"
195
- c << "-l ../../#{CONCOURSE_SCALE_VARS}"
199
+ c << "-l ../../#{CONCOURSE_DEPLOYMENT_VARS}"
200
+ ops_files.each do |ops_file|
201
+ c << "-o #{ops_file}"
202
+ end
196
203
  end.join(" ")
197
204
 
198
205
  Dir.chdir("concourse-bosh-deployment/cluster") do
@@ -200,66 +207,26 @@ module Concourse
200
207
  end
201
208
  end
202
209
 
203
- def letsencrypt_create
204
- external_dns_name = bosh_secrets['external_dns_name']
205
- if external_dns_name == bbl_external_ip
206
- error "Please set your external DNS name in #{BOSH_SECRETS}"
207
- end
208
-
209
- sh "bosh ssh web -c 'sudo chmod 777 /tmp'"
210
- sh "bosh ssh web -c 'sudo add-apt-repository -y ppa:certbot/certbot'"
211
- sh "bosh ssh web -c 'sudo apt-get update'"
212
- sh "bosh ssh web -c 'sudo apt-get install -y certbot'"
210
+ def db_connect
211
+ tempfile_cert = Tempfile.new
212
+ tempfile_key = Tempfile.new
213
+ tempfile_ca = Tempfile.new
213
214
  begin
214
- sh "bosh stop web"
215
- note "logging you into the web server. run this command: sudo certbot certonly --standalone -d \"#{external_dns_name}\""
216
- sh "bosh ssh web"
217
- ensure
218
- sh "bosh start web"
219
- end
220
- end
215
+ tempfile_cert.write bosh_secrets['postgres_client_cert']['certificate']
216
+ tempfile_key.write bosh_secrets['postgres_client_cert']['private_key']
217
+ tempfile_ca.write bosh_secrets['postgres_ca_cert']['certificate']
221
218
 
222
- def letsencrypt_backup
223
- ensure_in_gitcrypt LETSENCRYPT_BACKUP_FILE
224
- sh %Q{bosh ssh web -c 'sudo tar -zcvf /var/tmp/#{LETSENCRYPT_BACKUP_FILE} -C /etc letsencrypt'}
225
- sh %Q{bosh scp web:/var/tmp/#{LETSENCRYPT_BACKUP_FILE} .}
226
- end
219
+ tempfile_cert.close
220
+ tempfile_key.close
221
+ tempfile_ca.close
227
222
 
228
- def letsencrypt_import
229
- ensure_in_gitcrypt LETSENCRYPT_BACKUP_FILE
230
- external_dns_name = bosh_secrets['external_dns_name']
223
+ 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"}
231
224
 
232
- begin
233
- sh "tar -zxf #{LETSENCRYPT_BACKUP_FILE}"
234
- note "importing certificate and private key for #{external_dns_name} ..."
235
- bosh_secrets do |v|
236
- v["atc_tls"] ||= {}
237
- v["atc_tls"]["certificate"] = File.read "letsencrypt/live/#{external_dns_name}/fullchain.pem"
238
- v["atc_tls"]["private_key"] = File.read "letsencrypt/live/#{external_dns_name}/privkey.pem"
239
- end
240
- ensure
241
- sh "rm -rf letsencrypt"
242
- end
243
- end
244
-
245
- def letsencrypt_restore
246
- ensure_in_gitcrypt LETSENCRYPT_BACKUP_FILE
247
- sh "bosh ssh web -c 'sudo rm -rf /etc/letsencrypt /var/tmp/#{LETSENCRYPT_BACKUP_FILE}'"
248
- sh "bosh scp #{LETSENCRYPT_BACKUP_FILE} web:/var/tmp"
249
- sh "bosh ssh web -c 'sudo tar -zxvf /var/tmp/#{LETSENCRYPT_BACKUP_FILE} -C /etc'"
250
- sh "bosh ssh web -c 'sudo chown -R root:root /etc/letsencrypt'"
251
- end
252
-
253
- def letsencrypt_renew
254
- sh "bosh ssh web -c 'sudo chmod 1777 /tmp'" # see https://github.com/cloudfoundry/bosh-linux-stemcell-builder/issues/39
255
- sh "bosh ssh web -c 'sudo add-apt-repository -y ppa:certbot/certbot'"
256
- sh "bosh ssh web -c 'sudo apt-get update'"
257
- sh "bosh ssh web -c 'sudo apt-get install -y certbot'"
258
- begin
259
- sh "bosh stop web"
260
- sh "bosh ssh web -c 'sudo certbot renew'"
225
+ sh command
261
226
  ensure
262
- sh "bosh start web"
227
+ tempfile_cert.unlink
228
+ tempfile_key.unlink
229
+ tempfile_ca.unlink
263
230
  end
264
231
  end
265
232
 
@@ -330,32 +297,17 @@ module Concourse
330
297
  task "deploy" do
331
298
  bosh_deploy
332
299
  end
333
- end
334
-
335
- namespace "letsencrypt" do
336
- desc "create a cert"
337
- task "create" do
338
- letsencrypt_create
339
- end
340
-
341
- desc "backup web:/etc/letsencrypt to local disk"
342
- task "backup" do
343
- letsencrypt_backup
344
- end
345
-
346
- desc "import letsencrypt keys into `#{BOSH_SECRETS}` from backup"
347
- task "import" do
348
- letsencrypt_import
349
- end
350
300
 
351
- desc "restore web:/etc/letsencrypt from backup"
352
- task "restore" do
353
- letsencrypt_restore
301
+ desc "view interpolated manifest"
302
+ task "interpolate" do
303
+ bosh_deploy command: "interpolate"
354
304
  end
305
+ end
355
306
 
356
- desc "renew the certificate"
357
- task "renew" do
358
- letsencrypt_renew
307
+ namespace "db" do
308
+ desc "connect to the postgres database"
309
+ task "connect" do
310
+ db_connect
359
311
  end
360
312
  end
361
313
  end
@@ -0,0 +1,28 @@
1
+ - path: /releases/name=caddy?
2
+ type: replace
3
+ value:
4
+ name: "caddy"
5
+ version: "0.4.1"
6
+ url: "https://bosh.io/d/github.com/dpb587/caddy-bosh-release?v=0.4.1"
7
+ sha1: "7d9ca0c3e0bed5a68a5a202f864084108a41b47e"
8
+
9
+ # see https://github.com/dpb587/caddy-bosh-release/blob/master/manifests/caddy.yml
10
+ - path: /instance_groups/name=web/persistent_disk?
11
+ type: replace
12
+ value: 1024
13
+
14
+ # see https://github.com/dpb587/caddy-bosh-release/blob/master/manifests/examples/concourse-ops.yml
15
+ - path: /instance_groups/name=web/jobs/name=caddy?
16
+ type: replace
17
+ value:
18
+ name: "caddy"
19
+ release: "caddy"
20
+ properties:
21
+ caddyfile: |
22
+ ((external_host)) {
23
+ gzip
24
+ proxy / localhost:8080 {
25
+ transparent
26
+ websocket
27
+ }
28
+ }
@@ -1,5 +1,5 @@
1
1
  module Concourse
2
2
  class Deployer
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
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.1.0
4
+ version: 0.2.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-01-04 00:00:00.000000000 Z
11
+ date: 2019-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -100,6 +100,7 @@ files:
100
100
  - bin/setup
101
101
  - concourse-deployer.gemspec
102
102
  - lib/concourse/deployer.rb
103
+ - lib/concourse/deployer/operations/caddy.yml
103
104
  - lib/concourse/deployer/utils.rb
104
105
  - lib/concourse/deployer/version.rb
105
106
  homepage: https://github.com/flavorjones/concourse-deployer