Skip to content
This repository
Browse code

Migrate ccdb_postgres -> new postgres template

New postgres template is more generic and can be used
by all of ccdb, uaadb and acmdb jobs. Deployment manifest
should be updated in order to pick that change up.

Manifest changes:

1. use 'postgres' template in place of 'ccdb_postgres'

2. add property called 'db' to job-specific properties of every
   job using 'postgres' template. Property value should be a valid
   property name defined in the manifest, e.g.

   jobs:
   - template: postgres
     properties:
       db: ccdb
   ...
   properties
     ccdb: ...

3. use well-formed properties section that can be picked up by
   'postgres' template, e.g.

    ccdb:
      address: 172.23.242.12
      port: 5524
      roles:
      - tag: admin
        name: ccadmin
        password: tauBauWauZZb2
      databases:
      - tag: cc
        name: appcloud

   Please note that jobs consuming these properties should be able
   to locate role and database they need by traversing these properties
   and picking appropriate tags.

Change-Id: Ia1ff451bbcf3bb33ac35e3b7410323d0d7a7e65d
  • Loading branch information...
commit 3a1abefe7352c22b4fff70dee9ae27c111ba75c8 1 parent 1a89b14
authored
5  jobs/acm/templates/acm.yml.erb
... ...
@@ -1,4 +1,7 @@
1 1
 ---
  2
+<% db = properties.acmdb.databases.find { |db| db.tag == "acm" } %>
  3
+<% role = properties.acmdb.roles.find { |role| role.tag == "admin" } %>
  4
+
2 5
 pid: /var/vcap/sys/run/acm/acm.pid
3 6
 name: ACM
4 7
 port: 9090
@@ -8,7 +11,7 @@ logging:
8 11
   file: /var/vcap/sys/log/acm/acm.log
9 12
   syslog: vcap.acm
10 13
 db:
11  
-  database: postgres://<%= properties.acm.db.user %>:<%= properties.acm.db.password %>@<%= properties.acm.db.address %>:<%= properties.acm.db.port %>/<%= properties.acm.db.dbname %>
  14
+  database: postgres://<%= role.name %>:<%= role.password %>@<%= properties.acmdb.address %>:<%= properties.acmdb.port %>/<%= db.name %>
12 15
   max_connections: 25
13 16
   pool_timeout: 2000
14 17
 basic_auth:
9  jobs/cloud_controller/templates/cloud_controller.yml.erb
... ...
@@ -1,4 +1,7 @@
1 1
 ---
  2
+<% db = properties.ccdb.databases.find { |db| db.tag == "cc" } %>
  3
+<% db_role = properties.ccdb.roles.find { |role| role.tag == "admin" } %>
  4
+
2 5
 external_uri: api.<%= properties.domain %>
3 6
 description: <%= properties.description || "VMware's Cloud Application Platform" %>
4 7
 support_address: <%= properties.support_address || "http://support.cloudfoundry.com" %>
@@ -76,12 +79,12 @@ new_initial_placement: false
76 79
 
77 80
 database_environment:
78 81
   production:
79  
-    database: <%= properties.ccdb.dbname %>
  82
+    database: <%= db.name %>
80 83
     host: <%= properties.ccdb.address %>
81 84
     port: <%= properties.ccdb.port %>
82 85
     encoding: utf8
83  
-    username: <%= properties.ccdb.user %>
84  
-    password: <%= properties.ccdb.password %>
  86
+    username: <%= db_role.name %>
  87
+    password: <%= db_role.password %>
85 88
     pool: <%= properties.ccdb.pool_size %>
86 89
     timeout: 2000
87 90
     template: template0 # Required for utf8 encoding
9  jobs/health_manager/templates/cloud_controller.yml.erb
... ...
@@ -1,4 +1,7 @@
1 1
 ---
  2
+<% db = properties.ccdb.databases.find { |db| db.tag == "cc" } %>
  3
+<% db_role = properties.ccdb.roles.find { |role| role.tag == "admin" } %>
  4
+
2 5
 external_uri: api.<%= properties.domain %>
3 6
 local_route: <%= spec.networks.send(properties.networks.apps).ip %>
4 7
 allow_external_app_uris: false
@@ -24,12 +27,12 @@ mbus: nats://<%= properties.nats.user %>:<%= properties.nats.password %>@<%= pro
24 27
 rails_environment: production
25 28
 database_environment:
26 29
   production:
27  
-    database: <%= properties.ccdb.dbname %>
  30
+    database: <%= db.dbname %>
28 31
     host: <%= properties.ccdb.address %>
29 32
     port: <%= properties.ccdb.port %>
30 33
     encoding: utf8
31  
-    username: <%= properties.ccdb.user %>
32  
-    password: <%= properties.ccdb.password %>
  34
+    username: <%= db_role.name %>
  35
+    password: <%= db_role.password %>
33 36
     pool: <%= properties.ccdb.pool_size %>
34 37
     timeout: 2000
35 38
     template: template0 # Required for utf8 encoding
15  jobs/health_manager/templates/health_manager.yml.erb
... ...
@@ -1,6 +1,11 @@
1 1
 ---
2  
-local_route: <%= spec.networks.send(properties.networks.apps).ip %>
3  
-mbus: nats://<%= properties.nats.user %>:<%= properties.nats.password %>@<%= properties.nats.address %>:<%= properties.nats.port %>
  2
+<% db = properties.ccdb.databases.find { |db| db.tag == "cc" } %>
  3
+<% db_role = properties.ccdb.roles.find { |role| role.tag == "admin" } %>
  4
+<% network = spec.networks.send(properties.networks.apps) %>
  5
+<% nats = properties.nats %>
  6
+
  7
+local_route: <%= network.ip %>
  8
+mbus: nats://<%= nats.user %>:<%= nats.password %>@<%= nats.address %>:<%= nats.port %>
4 9
 logging:
5 10
   file: /var/vcap/sys/log/health_manager/health_manager.log
6 11
   <% if properties.syslog_aggregator %>
@@ -12,12 +17,12 @@ rails_environment: production
12 17
 index: <%= spec.index %>
13 18
 database_environment:
14 19
   production:
15  
-    database: <%= properties.ccdb.dbname %>
  20
+    database: <%= db.name %>
16 21
     host: <%= properties.ccdb.address %>
17 22
     port: <%= properties.ccdb.port %>
18 23
     encoding: utf8
19  
-    username: <%= properties.ccdb.user %>
20  
-    password: <%= properties.ccdb.password %>
  24
+    username: <%= db_role.name %>
  25
+    password: <%= db_role.password %>
21 26
     pool: <%= properties.ccdb.pool_size %>
22 27
     timeout: 2000
23 28
     template: template0 # Required for utf8 encoding
18  jobs/uaa/templates/uaa.yml.erb
... ...
@@ -1,4 +1,10 @@
1 1
 ---
  2
+<% uaa_db = properties.uaadb.databases.find { |db| db.tag == "uaa" } %>
  3
+<% uaa_role = properties.uaadb.roles.find { |role| role.tag == "admin" } %>
  4
+
  5
+<% cc_db = properties.ccdb.databases.find { |db| db.tag == "cc" } %>
  6
+<% cc_role = properties.ccdb.roles.find { |role| role.tag == "admin" } %>
  7
+
2 8
 pid: /var/vcap/sys/run/uaa.pid
3 9
 # nats message bus uri
4 10
 mbus: nats://<%= properties.nats.user %>:<%= properties.nats.password %>@<%= properties.nats.address %>:<%= properties.nats.port %>/
@@ -7,18 +13,18 @@ name: uaa
7 13
 
8 14
 database:
9 15
   driverClassName: org.postgresql.Driver
10  
-  url: jdbc:postgresql://<%= properties.uaa.db.address %>:<%= properties.uaa.db.port %>/<%= properties.uaa.db.dbname %>
11  
-  username: <%= properties.uaa.db.user %>
12  
-  password: <%= properties.uaa.db.password %>
  16
+  url: jdbc:postgresql://<%= properties.uaadb.address %>:<%= properties.uaadb.port %>/<%= uaa_db.name %>
  17
+  username: <%= uaa_role.name %>
  18
+  password: <%= uaa_role.password %>
13 19
 
14 20
 jvm_args: -Xmx512m
15 21
 spring_profiles: postgresql
16 22
 
17 23
 cloud_controller:
18 24
   database:
19  
-    url: jdbc:postgresql://<%= properties.ccdb.address %>:<%= properties.ccdb.port %>/<%= properties.ccdb.dbname %>
20  
-    username: <%= properties.ccdb.user %>
21  
-    password: <%= properties.ccdb.password %>
  25
+    url: jdbc:postgresql://<%= properties.ccdb.address %>:<%= properties.ccdb.port %>/<%= cc_db.name %>
  26
+    username: <%= cc_role.name %>
  27
+    password: <%= cc_role.password %>
22 28
 
23 29
 logging:
24 30
   config: /var/vcap/jobs/uaa/config/log4j.properties

Git Notes

review

Code-Review+2: Vadim Spivak <vspivak@vmware.com>
Code-Review+1: Martin Englund <menglund@vmware.com>
Code-Review+1: Joel D'sa <jdsa@vmware.com>
Verified+1: CI Master <cf-ci@rbcon.com>
Submitted-by: Oleg Shaldybin <olegs@vmware.com>
Submitted-at: Mon, 21 May 2012 18:13:55 +0000
Reviewed-on: http://reviews.cloudfoundry.org/5594
Project: cf-release
Branch: refs/heads/master

0 notes on commit 3a1abef

Please sign in to comment.
Something went wrong with that request. Please try again.