1 # -*- indent-tabs-mode: nil -*- # vi: set expandtab:
4 # add consul registration
6 # ============LICENSE_START====================================================
8 # =============================================================================
9 # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
10 # =============================================================================
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
15 # http://www.apache.org/licenses/LICENSE-2.0
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22 # ============LICENSE_END======================================================
24 tosca_definitions_version: cloudify_dsl_1_3
27 This blueprint is used to install and to uninstall a central postgres as a platform service.
28 This blueprint depends upon the deployment of the pgaas_plugin and Consul.
31 - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
32 - http://www.getcloudify.org/spec/openstack-plugin/1.4/plugin.yaml
33 - http://www.getcloudify.org/spec/fabric-plugin/1.4.1/plugin.yaml
35 - {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/type_files/dnsdesig/dns_types.yaml
36 - {{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/sshkeyshare/sshkey_types.yaml
37 - {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/type_files/relationship/1.0.0/node-type.yaml
38 - {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/type_files/pgaas_plugin/1.0.0/pgaas_types.yaml
44 default: 'VERSION-STAMP-GOES-HERE'
74 echo All output will be found in /tmp/ins.out and /tmp/ins.err
75 exec > /tmp/ins.out 2> /tmp/ins.err
77 if [ "$(dnsdomainname 2>/dev/null)" = "" ]
79 echo WARNING WARNING WARNING
80 echo The DNS DHCP settings did not work properly.
84 CONFDIR=/var/config/DCAE/chef/
87 CONF=$CONFDIR/pgaas-postgres.conf
91 DRTR_NODE_KSTOREFILE: /opt/app/dcae-certificate/keystore.jks
92 DRTR_NODE_KSTOREPASS: "No Certificate"
93 DRTR_NODE_PVTKEYPASS: "No Certificate"
95 PG_JAVA_HOME : /opt/app/java/jdk/jdk170
101 # invoking apt-get separately allows a failure to be ignored
102 for i in openjdk-7-jdk openjdk-8-jdk python-pip python3-pip curl gawk; do apt-get install -y $i;done
105 # prevent servers from starting
106 echo "exit 101" > /usr/sbin/policy-rc.d; chmod a+x /usr/sbin/policy-rc.d
108 # invoking apt-get separately allows a failure to be ignored
109 for i in postgresql libpq5 repmgr python-psycopg2 python3-psycopg2 libgetopt-java; do apt-get install -y $i; done
111 # allow servers to autostart again
112 rm -f /usr/sbin/policy-rc.d
114 ( umask 077; sed 's/^/*:*:*:postgres:/' < /root/.pgrspw > ~postgres/.pgpass; chown postgres:postgres ~postgres/.pgpass )
117 then echo "$CONF does not exist" 1>&2; exit 1
120 echo Look in /tmp/pgaas.out for output from installing PGaaS
121 NEXUS={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform }}/debs
122 for pkg in cdf_17.10.0-LATEST.deb pgaas_17.10.0-LATEST.deb
125 curl -s -k -f -o $OUT $NEXUS/$pkg
131 *00 ) WRITE=-write ;;
134 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}"
140 type: cloudify.openstack.nodes.KeyPair
142 private_key_path: { get_input: key_filename }
143 use_external_resource: True
144 resource_id: { get_input: keypair }
145 openstack_config: &open_conf
148 type: cloudify.openstack.nodes.Network
150 use_external_resource: True
151 resource_id: { get_input: private_net }
152 openstack_config: *open_conf
154 type: cloudify.openstack.nodes.SecurityGroup
156 use_external_resource: True
157 resource_id: { get_input: security_group }
158 openstack_config: *open_conf
161 type: dcae.nodes.ssh.keypair
164 type: cloudify.openstack.nodes.Port
168 - opt_name: 'domain-name'
169 opt_value: { get_input: location_domain }
170 openstack_config: *open_conf
172 - type: cloudify.relationships.contained_in
175 type: cloudify.openstack.nodes.FloatingIP
177 openstack_config: *open_conf
179 cloudify.interfaces.lifecycle:
183 floating_network_name: { get_input: public_net }
185 type: dcae.nodes.dns.arecord
187 fqdn: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
188 openstack: *open_conf
190 cloudify.interfaces.lifecycle:
195 - { get_attribute: [ floatingip_pgrs00, floating_ip_address ] }
197 - type: cloudify.relationships.depends_on
198 target: floatingip_pgrs00
200 type: cloudify.openstack.nodes.Server
203 image: { get_input: ubuntu1604image_id }
204 flavor: { get_input: flavor_id }
205 management_network_name: { get_input: private_net }
206 openstack_config: *open_conf
208 cloudify.interfaces.lifecycle:
212 name: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00' ] }
219 - { get_attribute: [ sharedsshkey_pgrs, public ] }
221 ' >/root/.sshkey/id_rsa.pub
223 - { get_attribute: [ sharedsshkey_pgrs, base64private ] }
225 ' | base64 -d >/root/.sshkey/id_rsa
226 chmod 700 /root/.sshkey
227 chmod 600 /root/.sshkey/*
228 ( umask 077; echo -n postgres | cat - /root/.sshkey/id_rsa | md5sum | awk '{ print $1 }' > /root/.pgrspw )
232 - { get_input: pgaas_cluster_name }
234 - "LOCATION_PREFIX='"
235 - { get_input: location_prefix }
237 - "LOCATION_DOMAIN='"
238 - { get_input: location_domain }
241 - { get_property: [ dns_pgrs00, fqdn ] }
244 - { get_attribute: [ host_pgrs00, ip ] }
247 - { get_property: [ dns_pgrs00, fqdn ] }
249 - { get_property: [ dns_pgrs01, fqdn ] }
251 - { get_input: vm_init_pgrs }
253 - type: cloudify.openstack.server_connected_to_port
254 target: fixedip_pgrs00
255 - type: cloudify.openstack.server_connected_to_security_group
256 target: security_group
257 - type: cloudify.openstack.server_connected_to_floating_ip
258 target: floatingip_pgrs00
259 - type: cloudify.openstack.server_connected_to_keypair
261 - type: cloudify.relationships.depends_on
263 - type: cloudify.relationships.depends_on
264 target: sharedsshkey_pgrs
266 type: cloudify.openstack.nodes.Port
270 - opt_name: 'domain-name'
271 opt_value: { get_input: location_domain }
272 openstack_config: *open_conf
274 - type: cloudify.relationships.contained_in
277 type: cloudify.openstack.nodes.FloatingIP
279 openstack_config: *open_conf
281 cloudify.interfaces.lifecycle:
285 floating_network_name: { get_input: public_net }
287 type: dcae.nodes.dns.arecord
289 fqdn: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '01.', { get_input: location_domain } ] }
290 openstack: *open_conf
292 cloudify.interfaces.lifecycle:
297 - { get_attribute: [ floatingip_pgrs01, floating_ip_address ] }
299 - type: cloudify.relationships.depends_on
300 target: floatingip_pgrs01
302 type: cloudify.openstack.nodes.Server
305 image: { get_input: ubuntu1604image_id }
306 flavor: { get_input: flavor_id }
307 management_network_name: { get_input: private_net }
308 openstack_config: *open_conf
310 cloudify.interfaces.lifecycle:
314 name: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '01' ] }
321 - { get_attribute: [ sharedsshkey_pgrs, public ] }
323 ' >/root/.sshkey/id_rsa.pub
325 - { get_attribute: [ sharedsshkey_pgrs, base64private ] }
327 ' | base64 -d >/root/.sshkey/id_rsa
328 chmod 700 /root/.sshkey
329 chmod 600 /root/.sshkey/*
330 ( umask 077; echo -n postgres | cat - /root/.sshkey/id_rsa | md5sum | awk '{ print $1 }' > /root/.pgrspw )
334 - { get_input: pgaas_cluster_name }
336 - "LOCATION_PREFIX='"
337 - { get_input: location_prefix }
339 - "LOCATION_DOMAIN='"
340 - { get_input: location_domain }
343 - { get_property: [ dns_pgrs00, fqdn ] }
346 - { get_attribute: [ host_pgrs01, ip ] }
349 - { get_property: [ dns_pgrs00, fqdn ] }
351 - { get_property: [ dns_pgrs01, fqdn ] }
353 - { get_input: vm_init_pgrs }
355 - type: cloudify.openstack.server_connected_to_port
356 target: fixedip_pgrs01
357 - type: cloudify.openstack.server_connected_to_security_group
358 target: security_group
359 - type: cloudify.openstack.server_connected_to_floating_ip
360 target: floatingip_pgrs01
361 - type: cloudify.openstack.server_connected_to_keypair
363 - type: cloudify.relationships.depends_on
365 - type: cloudify.relationships.depends_on
366 target: sharedsshkey_pgrs
370 type: dcae.nodes.dns.cnamerecord
372 fqdn: { concat: [ { get_input: location_prefix }, '-', { get_input: pgaas_cluster_name }, '-write.', { get_input: location_domain } ] }
373 openstack: *open_conf
375 cloudify.interfaces.lifecycle:
379 cname: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
382 type: dcae.nodes.dns.cnamerecord
384 fqdn: { concat: [ { get_input: location_prefix }, '-', { get_input: pgaas_cluster_name }, '.', { get_input: location_domain } ] }
385 openstack: *open_conf
387 cloudify.interfaces.lifecycle:
391 cname: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
393 # tie to pgaas_plugin database
395 type: dcae.nodes.pgaas.cluster
397 writerfqdn: { get_property: [ dns_pgrs_rw, fqdn ] }
398 readerfqdn: { get_property: [ dns_pgrs_ro, fqdn ] }
400 - type: dcae.relationships.pgaas_cluster_uses_sshkeypair
401 target: sharedsshkey_pgrs
402 - type: cloudify.relationships.depends_on
404 - type: cloudify.relationships.depends_on
409 value: { get_attribute: [host_pgrs00, ip] }
411 value: { get_attribute: [host_pgrs01, ip] }
413 value: { get_property: [ dns_pgrs_rw, fqdn ] }
415 value: { get_property: [ dns_pgrs_ro, fqdn ] }
417 value: { get_property: [ dns_pgrs00, fqdn ] }
419 value: { get_property: [ dns_pgrs01, fqdn ] }
421 value: { get_input: blueprint_version }