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 two-VM 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 }}/relationshipplugin/1.0.0/relationshipplugin_types.yaml"
35 - "{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/pgaas/1.1.0/pgaas_types.yaml"
40 default: '2018-04-27T00:31:38+0000'
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.
64 if [ "$(dnsdomainname 2>/dev/null)" != "" ]
67 echo The DNS DHCP settings still did not work properly.
69 if [ "$(dnsdomainname 2>/dev/null)" = "" ]
76 CONFDIR=/var/config/DCAE/chef/
79 CONF=$CONFDIR/pgaas-postgres.conf
83 DRTR_NODE_KSTOREFILE: /opt/app/dcae-certificate/keystore.jks
84 DRTR_NODE_KSTOREPASS: "No Certificate"
85 DRTR_NODE_PVTKEYPASS: "No Certificate"
87 PG_JAVA_HOME : /opt/app/java/jdk/jdk170
93 # invoking apt-get separately allows a failure to be ignored
94 for i in openjdk-7-jdk openjdk-8-jdk python-pip python3-pip curl gawk; do apt-get install -y $i;done
97 # prevent servers from starting
98 echo "exit 101" > /usr/sbin/policy-rc.d; chmod a+x /usr/sbin/policy-rc.d
100 # invoking apt-get separately allows a failure to be ignored
101 for i in postgresql libpq5 repmgr python-psycopg2 python3-psycopg2 libgetopt-java; do apt-get install -y $i; done
103 # allow servers to autostart again
104 rm -f /usr/sbin/policy-rc.d
106 ( umask 077; sed 's/^/*:*:*:postgres:/' < /root/.pgrspw > ~postgres/.pgpass; chown postgres:postgres ~postgres/.pgpass )
109 then echo "$CONF does not exist" 1>&2; exit 1
112 echo Look in /tmp/pgaas.out for output from installing PGaaS
113 NEXUS={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_storage_pgaas_debs_releases }}/debs
114 for pkg in cdf.deb-1.0.0 pgaas.deb-1.0.0
117 curl -s -k -f -o $OUT $NEXUS/$pkg
122 *00 ) WRITE=-write ;;
125 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}"
131 type: cloudify.openstack.nodes.KeyPair
133 private_key_path: { get_input: key_filename }
134 use_external_resource: True
135 resource_id: { get_input: keypair }
136 openstack_config: &open_conf
139 type: cloudify.openstack.nodes.Network
141 use_external_resource: True
142 resource_id: { get_input: private_net }
143 openstack_config: *open_conf
145 type: cloudify.openstack.nodes.SecurityGroup
147 use_external_resource: True
148 resource_id: { get_input: security_group }
149 openstack_config: *open_conf
152 type: ccsdk.nodes.ssh.keypair
155 type: cloudify.openstack.nodes.Port
159 - opt_name: 'domain-name'
160 opt_value: { get_input: location_domain }
161 openstack_config: *open_conf
163 - type: cloudify.relationships.contained_in
166 type: cloudify.openstack.nodes.FloatingIP
168 openstack_config: *open_conf
170 cloudify.interfaces.lifecycle:
174 floating_network_name: { get_input: public_net }
176 type: ccsdk.nodes.dns.arecord
178 fqdn: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
179 openstack: *open_conf
181 cloudify.interfaces.lifecycle:
186 - { get_attribute: [ floatingip_pgrs00, floating_ip_address ] }
188 - type: cloudify.relationships.depends_on
189 target: floatingip_pgrs00
191 type: cloudify.openstack.nodes.Server
194 image: { get_input: ubuntu1604image_id }
195 flavor: { get_input: flavor_id }
196 management_network_name: { get_input: private_net }
197 openstack_config: *open_conf
199 cloudify.interfaces.lifecycle:
203 name: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00' ] }
210 - { get_attribute: [ sharedsshkey_pgrs, public ] }
212 ' >/root/.sshkey/id_rsa.pub
214 - { get_attribute: [ sharedsshkey_pgrs, base64private ] }
216 ' | base64 -d >/root/.sshkey/id_rsa
217 chmod 700 /root/.sshkey
218 chmod 600 /root/.sshkey/*
219 ( umask 077; echo -n postgres | cat - /root/.sshkey/id_rsa | md5sum | awk '{ print $1 }' > /root/.pgrspw )
223 - { get_input: pgaas_cluster_name }
225 - "LOCATION_PREFIX='"
226 - { get_input: location_prefix }
228 - "LOCATION_DOMAIN='"
229 - { get_input: location_domain }
232 - { get_property: [ dns_pgrs00, fqdn ] }
235 - { get_attribute: [ floatingip_pgrs00, floating_ip_address ] }
238 - { get_property: [ dns_pgrs00, fqdn ] }
240 - { get_property: [ dns_pgrs01, fqdn ] }
242 - { get_input: vm_init_pgrs }
244 - type: cloudify.openstack.server_connected_to_port
245 target: fixedip_pgrs00
246 - type: cloudify.openstack.server_connected_to_security_group
247 target: security_group
248 - type: cloudify.openstack.server_connected_to_floating_ip
249 target: floatingip_pgrs00
250 - type: cloudify.openstack.server_connected_to_keypair
252 - type: cloudify.relationships.depends_on
254 - type: cloudify.relationships.depends_on
255 target: sharedsshkey_pgrs
257 type: cloudify.openstack.nodes.Port
261 - opt_name: 'domain-name'
262 opt_value: { get_input: location_domain }
263 openstack_config: *open_conf
265 - type: cloudify.relationships.contained_in
268 type: cloudify.openstack.nodes.FloatingIP
270 openstack_config: *open_conf
272 cloudify.interfaces.lifecycle:
276 floating_network_name: { get_input: public_net }
278 type: ccsdk.nodes.dns.arecord
280 fqdn: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '01.', { get_input: location_domain } ] }
281 openstack: *open_conf
283 cloudify.interfaces.lifecycle:
288 - { get_attribute: [ floatingip_pgrs01, floating_ip_address ] }
290 - type: cloudify.relationships.depends_on
291 target: floatingip_pgrs01
293 type: cloudify.openstack.nodes.Server
296 image: { get_input: ubuntu1604image_id }
297 flavor: { get_input: flavor_id }
298 management_network_name: { get_input: private_net }
299 openstack_config: *open_conf
301 cloudify.interfaces.lifecycle:
305 name: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '01' ] }
312 - { get_attribute: [ sharedsshkey_pgrs, public ] }
314 ' >/root/.sshkey/id_rsa.pub
316 - { get_attribute: [ sharedsshkey_pgrs, base64private ] }
318 ' | base64 -d >/root/.sshkey/id_rsa
319 chmod 700 /root/.sshkey
320 chmod 600 /root/.sshkey/*
321 ( umask 077; echo -n postgres | cat - /root/.sshkey/id_rsa | md5sum | awk '{ print $1 }' > /root/.pgrspw )
325 - { get_input: pgaas_cluster_name }
327 - "LOCATION_PREFIX='"
328 - { get_input: location_prefix }
330 - "LOCATION_DOMAIN='"
331 - { get_input: location_domain }
334 - { get_property: [ dns_pgrs00, fqdn ] }
337 - { get_attribute: [ floatingip_pgrs01, floating_ip_address ] }
340 - { get_property: [ dns_pgrs00, fqdn ] }
342 - { get_property: [ dns_pgrs01, fqdn ] }
344 - { get_input: vm_init_pgrs }
346 - type: cloudify.openstack.server_connected_to_port
347 target: fixedip_pgrs01
348 - type: cloudify.openstack.server_connected_to_security_group
349 target: security_group
350 - type: cloudify.openstack.server_connected_to_floating_ip
351 target: floatingip_pgrs01
352 - type: cloudify.openstack.server_connected_to_keypair
354 - type: cloudify.relationships.depends_on
356 - type: cloudify.relationships.depends_on
357 target: sharedsshkey_pgrs
361 type: ccsdk.nodes.dns.cnamerecord
363 fqdn: { concat: [ { get_input: location_prefix }, '-', { get_input: pgaas_cluster_name }, '-write.', { 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 } ] }
373 type: ccsdk.nodes.dns.cnamerecord
375 fqdn: { concat: [ { get_input: location_prefix }, '-', { get_input: pgaas_cluster_name }, '.', { get_input: location_domain } ] }
376 openstack: *open_conf
378 cloudify.interfaces.lifecycle:
382 cname: { concat: [ { get_input: location_prefix }, { get_input: pgaas_cluster_name }, '00.', { get_input: location_domain } ] }
384 # tie to pgaas_plugin database
386 type: dcae.nodes.pgaas.cluster
388 writerfqdn: { get_property: [ dns_pgrs_rw, fqdn ] }
389 readerfqdn: { get_property: [ dns_pgrs_ro, fqdn ] }
391 - type: dcae.relationships.pgaas_cluster_uses_sshkeypair
392 target: sharedsshkey_pgrs
393 - type: cloudify.relationships.depends_on
395 - type: cloudify.relationships.depends_on
400 value: { get_attribute: [host_pgrs00, ip] }
402 value: { get_attribute: [host_pgrs01, ip] }
404 value: { get_property: [ dns_pgrs_rw, fqdn ] }
406 value: { get_property: [ dns_pgrs_ro, fqdn ] }
408 value: { get_property: [ dns_pgrs00, fqdn ] }
410 value: { get_property: [ dns_pgrs01, fqdn ] }
412 value: { get_input: blueprint_version }