1 # -*- indent-tabs-mode: nil -*- # vi: set expandtab:
3 # ============LICENSE_START====================================================
5 # =============================================================================
6 # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
7 # =============================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 # ============LICENSE_END======================================================
21 tosca_definitions_version: cloudify_dsl_1_3
24 This blueprint is used to install and to uninstall a central postgres as a platform service.
25 This blueprint depends upon the deployment of the pgaas_plugin, the PGaaS Cinder volume, and Consul.
26 This blueprint is part of a suite of three blueprints that allow a PGaaS
27 cluster to be created that has persistent databases stored in Cinder.
28 pgaas-disk allocates the cinder volumes. It must be run first.
29 pgaas-cluster creates the PG service and attaches the cinder volumes. It must be run second.
30 pgaas-database creates a database. It must be run third, for each persistent database.
31 If the cluster is uninstalled, the persistent databases are unaffected.
32 If a database blueprint is uninstalled, the persistent database goes away.
33 If the disk blueprint is uninstalled, all persistent databases go away, along with the server instance.
36 - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
37 - http://www.getcloudify.org/spec/openstack-plugin/1.4/plugin.yaml
38 - http://www.getcloudify.org/spec/fabric-plugin/1.4.1/plugin.yaml
40 - "{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/dnsdesig/dns_types.yaml"
41 - "{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/type_files/relationshipplugin/1/relationshipplugin_types.yaml"
42 - "{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/pgaas/pgaas_types.yaml"
47 default: 'VERSION-STAMP-GOES-HERE'
54 {{ ONAPTEMPLATE_STANDARD_INPUTS_TYPES }}
60 echo All output will be found in /tmp/ins.out and /tmp/ins.err
61 exec > /tmp/ins.out 2> /tmp/ins.err
63 if [ "$(dnsdomainname 2>/dev/null)" = "" ]
65 echo WARNING WARNING WARNING
66 echo The DNS DHCP settings did not work properly.
70 CONFDIR=/var/config/DCAE/chef/
73 CONF=$CONFDIR/pgaas-postgres.conf
77 DRTR_NODE_KSTOREFILE: /opt/app/dcae-certificate/keystore.jks
78 DRTR_NODE_KSTOREPASS: "No Certificate"
79 DRTR_NODE_PVTKEYPASS: "No Certificate"
81 PG_JAVA_HOME : /opt/app/java/jdk/jdk170
87 # invoking apt-get separately allows a failure to be ignored
88 for i in openjdk-7-jdk openjdk-8-jdk python-pip python3-pip curl gawk; do apt-get install -y $i;done
91 # prevent servers from starting
92 echo "exit 101" > /usr/sbin/policy-rc.d; chmod a+x /usr/sbin/policy-rc.d
94 # invoking apt-get separately allows a failure to be ignored
95 for i in postgresql libpq5 repmgr python-psycopg2 python3-psycopg2 libgetopt-java; do apt-get install -y $i; done
97 # allow servers to autostart again
98 rm -f /usr/sbin/policy-rc.d
100 ( umask 077; sed 's/^/*:*:*:postgres:/' < /root/.pgrspw > ~postgres/.pgpass; chown postgres:postgres ~postgres/.pgpass )
103 then echo "$CONF does not exist" 1>&2; exit 1
106 echo Look in /tmp/pgaas.out for output from installing PGaaS
107 NEXUS={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform }}/debs
108 for pkg in cdf_17.10.0-LATEST.deb pgaas_17.10.0-LATEST.deb
111 curl -s -k -f -o $OUT $NEXUS/$pkg
117 *00 ) WRITE=-write ;;
120 curl -v -X PUT -H "Content-Type: application/json" "http://${LOCATION_PREFIX}cnsl00.${LOCATION_DOMAIN}:8500/v1/agent/service/register" -d '{"name" : "${CLUSTER_NAME}${WRITE}", "Address" : "${LOCAL_IP}", "Port" : 5432}"
126 type: cloudify.openstack.nodes.KeyPair
128 private_key_path: { get_input: key_filename }
129 use_external_resource: True
130 resource_id: { get_input: keypair }
131 openstack_config: &open_conf
134 type: cloudify.openstack.nodes.Network
136 use_external_resource: True
137 resource_id: { get_input: private_net }
138 openstack_config: *open_conf
140 type: cloudify.openstack.nodes.SecurityGroup
142 use_external_resource: True
143 resource_id: { get_input: security_group }
144 openstack_config: *open_conf
147 type: cloudify.openstack.nodes.Port
151 - opt_name: 'domain-name'
152 opt_value: { get_input: location_domain }
153 openstack_config: *open_conf
155 - type: cloudify.relationships.contained_in
158 type: cloudify.openstack.nodes.FloatingIP
160 openstack_config: *open_conf
162 cloudify.interfaces.lifecycle:
166 floating_network_name: { get_input: public_net }
168 type: ccsdk.nodes.dns.arecord
170 fqdn: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
171 openstack: *open_conf
173 cloudify.interfaces.lifecycle:
178 - { get_attribute: [ floatingip_pgrs00, floating_ip_address ] }
180 - type: cloudify.relationships.depends_on
181 target: floatingip_pgrs00
183 type: cloudify.openstack.nodes.Server
186 image: { get_input: ubuntu1604image_id }
187 flavor: { get_input: flavor_id }
188 management_network_name: { get_input: private_net }
189 openstack_config: *open_conf
191 cloudify.interfaces.lifecycle:
195 name: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00' ] }
202 - { get_attribute: [ pgaas_cluster, public ] }
204 ' >/root/.sshkey/id_rsa.pub
206 - { get_attribute: [ pgaas_cluster, base64private ] }
208 ' | base64 -d >/root/.sshkey/id_rsa
209 chmod 700 /root/.sshkey
210 chmod 600 /root/.sshkey/*
211 ( umask 077; echo -n postgres | cat - /root/.sshkey/id_rsa | md5sum | awk '{ print $1 }' > /root/.pgrspw )
215 - { get_input: pgaas_cluster_name }
217 - "LOCATION_PREFIX='"
218 - { get_input: location_prefix }
220 - "LOCATION_DOMAIN='"
221 - { get_input: location_domain }
224 - { get_property: [ dns_pgrs00, fqdn ] }
227 - { get_attribute: [ host_pgrs00, ip ] }
230 - { get_property: [ dns_pgrs00, fqdn ] }
232 - { get_property: [ dns_pgrs01, fqdn ] }
234 - { get_input: vm_init_pgrs }
236 - type: cloudify.openstack.server_connected_to_port
237 target: fixedip_pgrs00
238 - type: cloudify.openstack.server_connected_to_security_group
239 target: security_group
240 - type: cloudify.openstack.server_connected_to_floating_ip
241 target: floatingip_pgrs00
242 - type: cloudify.openstack.server_connected_to_keypair
244 - type: cloudify.relationships.depends_on
246 - type: cloudify.relationships.depends_on
247 target: pgaas_cluster
249 type: cloudify.openstack.nodes.Port
253 - opt_name: 'domain-name'
254 opt_value: { get_input: location_domain }
255 openstack_config: *open_conf
257 - type: cloudify.relationships.contained_in
260 type: cloudify.openstack.nodes.FloatingIP
262 openstack_config: *open_conf
264 cloudify.interfaces.lifecycle:
268 floating_network_name: { get_input: public_net }
270 type: ccsdk.nodes.dns.arecord
272 fqdn: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '01.', { get_input: location_domain } ] }
273 openstack: *open_conf
275 cloudify.interfaces.lifecycle:
280 - { get_attribute: [ floatingip_pgrs01, floating_ip_address ] }
282 - type: cloudify.relationships.depends_on
283 target: floatingip_pgrs01
285 type: cloudify.openstack.nodes.Server
288 image: { get_input: ubuntu1604image_id }
289 flavor: { get_input: flavor_id }
290 management_network_name: { get_input: private_net }
291 openstack_config: *open_conf
293 cloudify.interfaces.lifecycle:
297 name: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '01' ] }
304 - { get_attribute: [ pgaas_cluster, public ] }
306 ' >/root/.sshkey/id_rsa.pub
308 - { get_attribute: [ pgaas_cluster, base64private ] }
310 ' | base64 -d >/root/.sshkey/id_rsa
311 chmod 700 /root/.sshkey
312 chmod 600 /root/.sshkey/*
313 ( umask 077; echo -n postgres | cat - /root/.sshkey/id_rsa | md5sum | awk '{ print $1 }' > /root/.pgrspw )
317 - { get_input: pgaas_cluster_name }
319 - "LOCATION_PREFIX='"
320 - { get_input: location_prefix }
322 - "LOCATION_DOMAIN='"
323 - { get_input: location_domain }
326 - { get_property: [ dns_pgrs00, fqdn ] }
329 - { get_attribute: [ host_pgrs01, ip ] }
332 - { get_property: [ dns_pgrs00, fqdn ] }
334 - { get_property: [ dns_pgrs01, fqdn ] }
336 - { get_input: vm_init_pgrs }
338 - type: cloudify.openstack.server_connected_to_port
339 target: fixedip_pgrs01
340 - type: cloudify.openstack.server_connected_to_security_group
341 target: security_group
342 - type: cloudify.openstack.server_connected_to_floating_ip
343 target: floatingip_pgrs01
344 - type: cloudify.openstack.server_connected_to_keypair
346 - type: cloudify.relationships.depends_on
348 - type: cloudify.relationships.depends_on
349 target: pgaas_cluster
353 type: cloudify.openstack.nodes.Volume
355 resource_id: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00' ] }
356 openstack_config: *open_conf
357 use_external_resource: True
359 - type: cloudify.openstack.volume_attached_to_server
363 type: cloudify.openstack.nodes.Volume
365 resource_id: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '01' ] }
366 openstack_config: *open_conf
367 use_external_resource: True
369 - type: cloudify.openstack.volume_attached_to_server
374 type: ccsdk.nodes.dns.cnamerecord
376 fqdn: { concat: [ { get_input: location_prefix }, '-', { get_input: pgaas_cluster_name }, '-write.', { get_input: location_domain } ] }
377 openstack: *open_conf
379 cloudify.interfaces.lifecycle:
383 cname: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
386 type: ccsdk.nodes.dns.cnamerecord
388 fqdn: { concat: [ { get_input: location_prefix }, '-', { get_input: pgaas_cluster_name }, '.', { get_input: location_domain } ] }
389 openstack: *open_conf
391 cloudify.interfaces.lifecycle:
395 cname: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
397 # tie to pgaas_plugin database
399 type: dcae.nodes.pgaas.cluster
401 writerfqdn: { get_property: [ dns_pgrs_rw, fqdn ] }
404 - type: cloudify.relationships.depends_on
406 - type: cloudify.relationships.depends_on
411 value: { get_attribute: [host_pgrs00, ip] }
413 value: { get_attribute: [host_pgrs01, ip] }
415 value: { get_property: [ dns_pgrs_rw, fqdn ] }
417 value: { get_property: [ dns_pgrs_ro, fqdn ] }
419 value: { get_property: [ dns_pgrs00, fqdn ] }
421 value: { get_property: [ dns_pgrs01, fqdn ] }
423 value: { get_input: blueprint_version }