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 and Consul.
28 - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
29 - http://www.getcloudify.org/spec/openstack-plugin/1.4/plugin.yaml
30 - http://www.getcloudify.org/spec/fabric-plugin/1.4.1/plugin.yaml
32 - "{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/dnsdesig/dns_types.yaml"
33 - "{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/sshkeyshare/sshkey_types.yaml"
34 - "{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/type_files/relationshipplugin/1/relationshipplugin_types.yaml"
35 - "{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/pgaas/pgaas_types.yaml"
40 default: 'VERSION-STAMP-GOES-HERE'
47 {{ ONAPTEMPLATE_STANDARD_INPUTS_TYPES }}
53 echo All output will be found in /tmp/ins.out and /tmp/ins.err
54 exec > /tmp/ins.out 2> /tmp/ins.err
56 if [ "$(dnsdomainname 2>/dev/null)" = "" ]
58 echo WARNING WARNING WARNING
59 echo The DNS DHCP settings did not work properly.
63 CONFDIR=/var/config/DCAE/chef/
66 CONF=$CONFDIR/pgaas-postgres.conf
70 DRTR_NODE_KSTOREFILE: /opt/app/dcae-certificate/keystore.jks
71 DRTR_NODE_KSTOREPASS: "No Certificate"
72 DRTR_NODE_PVTKEYPASS: "No Certificate"
74 PG_JAVA_HOME : /opt/app/java/jdk/jdk170
80 # invoking apt-get separately allows a failure to be ignored
81 for i in openjdk-7-jdk openjdk-8-jdk python-pip python3-pip curl gawk; do apt-get install -y $i;done
84 # prevent servers from starting
85 echo "exit 101" > /usr/sbin/policy-rc.d; chmod a+x /usr/sbin/policy-rc.d
87 # invoking apt-get separately allows a failure to be ignored
88 for i in postgresql libpq5 repmgr python-psycopg2 python3-psycopg2 libgetopt-java; do apt-get install -y $i; done
90 # allow servers to autostart again
91 rm -f /usr/sbin/policy-rc.d
93 ( umask 077; sed 's/^/*:*:*:postgres:/' < /root/.pgrspw > ~postgres/.pgpass; chown postgres:postgres ~postgres/.pgpass )
96 then echo "$CONF does not exist" 1>&2; exit 1
99 echo Look in /tmp/pgaas.out for output from installing PGaaS
100 NEXUS={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform }}/debs
101 for pkg in cdf_17.10.0-LATEST.deb pgaas_17.10.0-LATEST.deb
104 curl -s -k -f -o $OUT $NEXUS/$pkg
110 *00 ) WRITE=-write ;;
113 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}"
119 type: cloudify.openstack.nodes.KeyPair
121 private_key_path: { get_input: key_filename }
122 use_external_resource: True
123 resource_id: { get_input: keypair }
124 openstack_config: &open_conf
127 type: cloudify.openstack.nodes.Network
129 use_external_resource: True
130 resource_id: { get_input: private_net }
131 openstack_config: *open_conf
133 type: cloudify.openstack.nodes.SecurityGroup
135 use_external_resource: True
136 resource_id: { get_input: security_group }
137 openstack_config: *open_conf
140 type: ccsdk.nodes.ssh.keypair
143 type: cloudify.openstack.nodes.Port
147 - opt_name: 'domain-name'
148 opt_value: { get_input: location_domain }
149 openstack_config: *open_conf
151 - type: cloudify.relationships.contained_in
154 type: cloudify.openstack.nodes.FloatingIP
156 openstack_config: *open_conf
158 cloudify.interfaces.lifecycle:
162 floating_network_name: { get_input: public_net }
164 type: ccsdk.nodes.dns.arecord
166 fqdn: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
167 openstack: *open_conf
169 cloudify.interfaces.lifecycle:
174 - { get_attribute: [ floatingip_pgrs00, floating_ip_address ] }
176 - type: cloudify.relationships.depends_on
177 target: floatingip_pgrs00
179 type: cloudify.openstack.nodes.Server
182 image: { get_input: ubuntu1604image_id }
183 flavor: { get_input: flavor_id }
184 management_network_name: { get_input: private_net }
185 openstack_config: *open_conf
187 cloudify.interfaces.lifecycle:
191 name: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00' ] }
198 - { get_attribute: [ sharedsshkey_pgrs, public ] }
200 ' >/root/.sshkey/id_rsa.pub
202 - { get_attribute: [ sharedsshkey_pgrs, base64private ] }
204 ' | base64 -d >/root/.sshkey/id_rsa
205 chmod 700 /root/.sshkey
206 chmod 600 /root/.sshkey/*
207 ( umask 077; echo -n postgres | cat - /root/.sshkey/id_rsa | md5sum | awk '{ print $1 }' > /root/.pgrspw )
211 - { get_input: pgaas_cluster_name }
213 - "LOCATION_PREFIX='"
214 - { get_input: location_prefix }
216 - "LOCATION_DOMAIN='"
217 - { get_input: location_domain }
220 - { get_property: [ dns_pgrs00, fqdn ] }
223 - { get_attribute: [ host_pgrs00, ip ] }
226 - { get_property: [ dns_pgrs00, fqdn ] }
228 - { get_property: [ dns_pgrs01, fqdn ] }
230 - { get_input: vm_init_pgrs }
232 - type: cloudify.openstack.server_connected_to_port
233 target: fixedip_pgrs00
234 - type: cloudify.openstack.server_connected_to_security_group
235 target: security_group
236 - type: cloudify.openstack.server_connected_to_floating_ip
237 target: floatingip_pgrs00
238 - type: cloudify.openstack.server_connected_to_keypair
240 - type: cloudify.relationships.depends_on
242 - type: cloudify.relationships.depends_on
243 target: sharedsshkey_pgrs
245 type: cloudify.openstack.nodes.Port
249 - opt_name: 'domain-name'
250 opt_value: { get_input: location_domain }
251 openstack_config: *open_conf
253 - type: cloudify.relationships.contained_in
256 type: cloudify.openstack.nodes.FloatingIP
258 openstack_config: *open_conf
260 cloudify.interfaces.lifecycle:
264 floating_network_name: { get_input: public_net }
266 type: ccsdk.nodes.dns.arecord
268 fqdn: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '01.', { get_input: location_domain } ] }
269 openstack: *open_conf
271 cloudify.interfaces.lifecycle:
276 - { get_attribute: [ floatingip_pgrs01, floating_ip_address ] }
278 - type: cloudify.relationships.depends_on
279 target: floatingip_pgrs01
281 type: cloudify.openstack.nodes.Server
284 image: { get_input: ubuntu1604image_id }
285 flavor: { get_input: flavor_id }
286 management_network_name: { get_input: private_net }
287 openstack_config: *open_conf
289 cloudify.interfaces.lifecycle:
293 name: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '01' ] }
300 - { get_attribute: [ sharedsshkey_pgrs, public ] }
302 ' >/root/.sshkey/id_rsa.pub
304 - { get_attribute: [ sharedsshkey_pgrs, base64private ] }
306 ' | base64 -d >/root/.sshkey/id_rsa
307 chmod 700 /root/.sshkey
308 chmod 600 /root/.sshkey/*
309 ( umask 077; echo -n postgres | cat - /root/.sshkey/id_rsa | md5sum | awk '{ print $1 }' > /root/.pgrspw )
313 - { get_input: pgaas_cluster_name }
315 - "LOCATION_PREFIX='"
316 - { get_input: location_prefix }
318 - "LOCATION_DOMAIN='"
319 - { get_input: location_domain }
322 - { get_property: [ dns_pgrs00, fqdn ] }
325 - { get_attribute: [ host_pgrs01, ip ] }
328 - { get_property: [ dns_pgrs00, fqdn ] }
330 - { get_property: [ dns_pgrs01, fqdn ] }
332 - { get_input: vm_init_pgrs }
334 - type: cloudify.openstack.server_connected_to_port
335 target: fixedip_pgrs01
336 - type: cloudify.openstack.server_connected_to_security_group
337 target: security_group
338 - type: cloudify.openstack.server_connected_to_floating_ip
339 target: floatingip_pgrs01
340 - type: cloudify.openstack.server_connected_to_keypair
342 - type: cloudify.relationships.depends_on
344 - type: cloudify.relationships.depends_on
345 target: sharedsshkey_pgrs
349 type: ccsdk.nodes.dns.cnamerecord
351 fqdn: { concat: [ { get_input: location_prefix }, '-', { get_input: pgaas_cluster_name }, '-write.', { get_input: location_domain } ] }
352 openstack: *open_conf
354 cloudify.interfaces.lifecycle:
358 cname: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
361 type: ccsdk.nodes.dns.cnamerecord
363 fqdn: { concat: [ { get_input: location_prefix }, '-', { get_input: pgaas_cluster_name }, '.', { get_input: location_domain } ] }
364 openstack: *open_conf
366 cloudify.interfaces.lifecycle:
370 cname: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
372 # tie to pgaas_plugin database
374 type: dcae.nodes.pgaas.cluster
376 writerfqdn: { get_property: [ dns_pgrs_rw, fqdn ] }
377 readerfqdn: { get_property: [ dns_pgrs_ro, fqdn ] }
379 - type: dcae.relationships.pgaas_cluster_uses_sshkeypair
380 target: sharedsshkey_pgrs
381 - type: cloudify.relationships.depends_on
383 - type: cloudify.relationships.depends_on
388 value: { get_attribute: [host_pgrs00, ip] }
390 value: { get_attribute: [host_pgrs01, ip] }
392 value: { get_property: [ dns_pgrs_rw, fqdn ] }
394 value: { get_property: [ dns_pgrs_ro, fqdn ] }
396 value: { get_property: [ dns_pgrs00, fqdn ] }
398 value: { get_property: [ dns_pgrs01, fqdn ] }
400 value: { get_input: blueprint_version }