Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # ============LICENSE_START========================================== |
| 4 | # =================================================================== |
| 5 | # Copyright © 2017 AT&T Intellectual Property. All rights reserved. |
| 6 | # =================================================================== |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | # you may not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # ============LICENSE_END============================================ |
| 19 | # |
| 20 | # ECOMP and OpenECOMP are trademarks |
| 21 | # and service marks of AT&T Intellectual Property. |
| 22 | # |
| 23 | |
| 24 | # URLs for artifacts needed for installation |
| 25 | DESIGTYPES={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/dnsdesig/dns_types.yaml |
| 26 | DESIGPLUG={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/plugins/dnsdesig-1.0.0-py27-none-any.wgn |
| 27 | SSHKEYTYPES={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/sshkeyshare/sshkey_types.yaml |
| 28 | SSHKEYPLUG={{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/plugins/sshkeyshare-1.0.0-py27-none-any.wgn |
| 29 | OSPLUGINZIP=https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/1.4.zip |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 30 | OSPLUGINWGN=https://github.com/cloudify-cosmo/cloudify-openstack-plugin/releases/download/2.2.0/cloudify_openstack_plugin-2.2.0-py27-none-linux_x86_64-centos-Core.wgn |
| 31 | |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 32 | PLATBPSRC={{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases }}/blueprints |
| 33 | DOCKERBP=DockerBP.yaml |
| 34 | CBSBP=config_binding_service.yaml |
Jack Lucas | 53322ff | 2017-11-01 19:25:06 +0000 | [diff] [blame] | 35 | PGBP=pgaas-onevm.yaml |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 36 | CDAPBP=cdapbp7.yaml |
| 37 | CDAPBROKERBP=cdap_broker.yaml |
| 38 | INVBP=inventory.yaml |
| 39 | DHBP=DeploymentHandler.yaml |
| 40 | PHBP=policy_handler.yaml |
Jack Lucas | 53322ff | 2017-11-01 19:25:06 +0000 | [diff] [blame] | 41 | VESBP=ves.yaml |
| 42 | TCABP=tca.yaml |
| 43 | HRULESBP=holmes-rules.yaml |
| 44 | HENGINEBP=holmes-engine.yaml |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 45 | |
| 46 | DOCKERBPURL="${PLATBPSRC}/${DOCKERBP}" |
| 47 | CBSBPURL="${PLATBPSRC}/${CBSBP}" |
Jack Lucas | 53322ff | 2017-11-01 19:25:06 +0000 | [diff] [blame] | 48 | PGBPURL=${PLATBPSRC}/${PGBP} |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 49 | CDAPBPURL="${PLATBPSRC}/${CDAPBP}" |
| 50 | CDAPBROKERBPURL="${PLATBPSRC}/${CDAPBROKERBP}" |
| 51 | INVBPURL="${PLATBPSRC}/${INVBP}" |
| 52 | DHBPURL="${PLATBPSRC}/${DHBP}" |
| 53 | PHBPURL="${PLATBPSRC}/${PHBP}" |
Jack Lucas | 53322ff | 2017-11-01 19:25:06 +0000 | [diff] [blame] | 54 | VESBPURL="${PLATBPSRC}/${VESBP}" |
| 55 | TCABPURL="${PLATBPSRC}/${TCABP}" |
| 56 | HRULESBPURL="${PLATBPSRC}/${HRULESBP}" |
| 57 | HENGINEBPURL="${PLATBPSRC}/${HENGINEBP}" |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 58 | |
| 59 | LOCATIONID=$(printenv LOCATION) |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 60 | |
| 61 | # Make sure ssh doesn't prompt for new host or choke on a new host with an IP it's seen before |
| 62 | SSHOPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" |
| 63 | STARTDIR=$(pwd) |
| 64 | |
Lusheng Ji | 10388fd | 2017-10-20 16:14:38 -0400 | [diff] [blame] | 65 | # clear out files for writing out floating IP addresses |
| 66 | rm -f "$STARTDIR"/config/runtime.ip.consul |
| 67 | rm -f "$STARTDIR"/config/runtime.ip.cm |
| 68 | |
| 69 | |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 70 | SSHUSER=centos |
| 71 | PVTKEY=./config/key |
| 72 | INPUTS=./config/inputs.yaml |
| 73 | |
Lusheng Ji | d92d448 | 2017-09-21 05:42:28 +0000 | [diff] [blame] | 74 | if [ "$LOCATION" = "" ] |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 75 | then |
| 76 | echo 'Environment variable LOCATION not set. Should be set to location ID for this installation.' |
| 77 | exit 1 |
| 78 | fi |
| 79 | |
| 80 | set -e |
| 81 | set -x |
| 82 | |
| 83 | # Docker workaround for SSH key |
| 84 | # In order for the container to be able to access the key when it's mounted from the Docker host, |
| 85 | # the key file has to be world-readable. But ssh itself will not work with a private key that's world readable. |
| 86 | # So we make a copy and change permissions on the copy. |
| 87 | # NB -- the key on the Docker host has to be world-readable, which means that, from the host machine, you |
| 88 | # can't use it with ssh. It needs to be a world-readable COPY. |
| 89 | PVTKEY=./key600 |
| 90 | cp ./config/key ${PVTKEY} |
| 91 | chmod 600 ${PVTKEY} |
| 92 | |
| 93 | # Create a virtual environment |
| 94 | virtualenv dcaeinstall |
| 95 | source dcaeinstall/bin/activate |
| 96 | |
| 97 | # Install Cloudify |
| 98 | pip install cloudify==3.4.0 |
| 99 | |
| 100 | # Install the Cloudify OpenStack plugin |
| 101 | wget -qO- ${OSPLUGINZIP} > openstack.zip |
| 102 | pip install openstack.zip |
| 103 | |
| 104 | # Spin up a VM |
| 105 | |
| 106 | # Get the Designate and SSH key type files and plugins |
| 107 | mkdir types |
| 108 | wget -qO- ${DESIGTYPES} > types/dns_types.yaml |
| 109 | wget -qO- ${SSHKEYTYPES} > types/sshkey_types.yaml |
| 110 | |
| 111 | wget -O dnsdesig.wgn ${DESIGPLUG} |
| 112 | wget -O sshkeyshare.wgn ${SSHKEYPLUG} |
| 113 | |
| 114 | wagon install -s dnsdesig.wgn |
| 115 | wagon install -s sshkeyshare.wgn |
| 116 | |
| 117 | ## Fix up the inputs file to get the private key locally |
| 118 | sed -e "s#key_filename:.*#key_filename: $PVTKEY#" < ${INPUTS} > /tmp/local_inputs |
| 119 | |
| 120 | # Now install the VM |
| 121 | # Don't exit on error after this point--keep container running so we can do uninstalls after a failure |
| 122 | set +e |
Lusheng Ji | 557c2cd | 2017-10-25 13:36:54 -0400 | [diff] [blame] | 123 | if wget -O /tmp/centos_vm.yaml {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases }}/blueprints/centos_vm.yaml; then |
| 124 | mv -f /tmp/centos_vm.yaml ./blueprints/ |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 125 | echo "Succeeded in getting the newest centos_vm.yaml" |
| 126 | else |
| 127 | echo "Failed to update centos_vm.yaml, using default version" |
Lusheng Ji | 557c2cd | 2017-10-25 13:36:54 -0400 | [diff] [blame] | 128 | rm -f /tmp/centos_vm.yaml |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 129 | fi |
| 130 | set -e |
| 131 | cfy local init --install-plugins -p ./blueprints/centos_vm.yaml -i /tmp/local_inputs -i "datacenter=$LOCATION" |
| 132 | cfy local execute -w install --task-retries=10 |
| 133 | PUBIP=$(cfy local outputs | grep -Po '"public_ip": "\K.*?(?=")') |
| 134 | |
Lusheng Ji | 3e6e3ad | 2017-11-20 14:06:52 -0500 | [diff] [blame^] | 135 | # wait till the cloudify manager's sshd ready |
| 136 | while ! nc -z -v -w5 ${PUBIP} 22; do echo "."; done |
Lusheng Ji | 557c2cd | 2017-10-25 13:36:54 -0400 | [diff] [blame] | 137 | sleep 10 |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 138 | |
| 139 | echo "Installing Cloudify Manager on ${PUBIP}." |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 140 | PVTIP=$(ssh $SSHOPTS -i "$PVTKEY" "$SSHUSER"@"$PUBIP" 'echo PVTIP=`curl --silent http://169.254.169.254/2009-04-04/meta-data/local-ipv4`' | grep PVTIP | sed 's/PVTIP=//') |
| 141 | if [ "$PVTIP" = "" ] |
| 142 | then |
Lusheng Ji | 3e6e3ad | 2017-11-20 14:06:52 -0500 | [diff] [blame^] | 143 | echo Cannot access specified machine at $PUBIP using supplied credentials |
| 144 | exit |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 145 | fi |
| 146 | |
| 147 | |
| 148 | # Copy private key onto Cloudify Manager VM |
| 149 | PVTKEYPATH=$(cat ${INPUTS} | grep "key_filename" | cut -d "'" -f2) |
| 150 | PVTKEYNAME=$(basename $PVTKEYPATH) |
| 151 | PVTKEYDIR=$(dirname $PVTKEYPATH) |
| 152 | scp $SSHOPTS -i $PVTKEY $PVTKEY $SSHUSER@$PUBIP:/tmp/$PVTKEYNAME |
| 153 | ssh -t $SSHOPTS -i $PVTKEY $SSHUSER@$PUBIP sudo mkdir -p $PVTKEYDIR |
| 154 | ssh -t $SSHOPTS -i $PVTKEY $SSHUSER@$PUBIP sudo mv /tmp/$PVTKEYNAME $PVTKEYPATH |
| 155 | |
| 156 | ESMAGIC=$(uuidgen -r) |
| 157 | WORKDIR=$HOME/cmtmp |
| 158 | BSDIR=$WORKDIR/cmbootstrap |
| 159 | PVTKEY2=$BSDIR/id_rsa.cfybootstrap |
| 160 | TMPBASE=$WORKDIR/tmp |
| 161 | TMPDIR=$TMPBASE/lib |
| 162 | SRCS=$WORKDIR/srcs.tar |
| 163 | TOOL=$WORKDIR/tool.py |
| 164 | rm -rf $WORKDIR |
| 165 | mkdir -p $BSDIR $TMPDIR/cloudify/wheels $TMPDIR/cloudify/sources $TMPDIR/manager |
| 166 | chmod 700 $WORKDIR |
| 167 | cp "$PVTKEY" $PVTKEY2 |
| 168 | cat >$TOOL <<!EOF |
| 169 | #!/usr/local/bin/python |
| 170 | # |
| 171 | import yaml |
| 172 | import sys |
| 173 | bsdir = sys.argv[1] |
| 174 | with open(bsdir + '/simple-manager-blueprint-inputs.yaml', 'r') as f: |
| 175 | inpyaml = yaml.load(f) |
| 176 | with open(bsdir + '/simple-manager-blueprint.yaml', 'r') as f: |
| 177 | bpyaml = yaml.load(f) |
| 178 | for param, value in bpyaml['inputs'].items(): |
| 179 | if value.has_key('default') and not inpyaml.has_key(param): |
| 180 | inpyaml[param] = value['default'] |
| 181 | print inpyaml['manager_resources_package'] |
| 182 | !EOF |
| 183 | |
| 184 | # |
| 185 | # Try to disable attempt to download virtualenv when not needed |
| 186 | # |
| 187 | ssh $SSHOPTS -t -i $PVTKEY2 $SSHUSER@$PUBIP 'sudo bash -xc "echo y; mkdir -p /root/.virtualenv; echo '"'"'[virtualenv]'"'"' >/root/.virtualenv/virtualenv.ini; echo no-download=true >>/root/.virtualenv/virtualenv.ini"' |
| 188 | |
| 189 | # Gather installation artifacts |
| 190 | # from documentation, URL for manager blueprints archive |
| 191 | BSURL=https://github.com/cloudify-cosmo/cloudify-manager-blueprints/archive/3.4.tar.gz |
| 192 | BSFILE=$(basename $BSURL) |
| 193 | |
| 194 | umask 022 |
| 195 | wget -qO- $BSURL >$BSDIR/$BSFILE |
| 196 | cd $BSDIR |
| 197 | tar xzvf $BSFILE |
| 198 | MRPURL=$(python $TOOL $BSDIR/cloudify-manager-blueprints-3.4) |
| 199 | MRPFILE=$(basename $MRPURL) |
| 200 | wget -qO- $MRPURL >$TMPDIR/cloudify/sources/$MRPFILE |
| 201 | |
| 202 | tar cf $SRCS -C $TMPDIR cloudify |
| 203 | rm -rf $TMPBASE |
| 204 | # |
| 205 | # Load required package files onto VM |
| 206 | # |
| 207 | scp $SSHOPTS -i $PVTKEY2 $SRCS $SSHUSER@$PUBIP:/tmp/. |
| 208 | ssh -t $SSHOPTS -i $PVTKEY2 $SSHUSER@$PUBIP 'sudo bash -xc "cd /opt; tar xf /tmp/srcs.tar; chown -R root:root /opt/cloudify /opt/manager; rm -rf /tmp/srcs.tar"' |
| 209 | # |
| 210 | # Install config file -- was done by DCAE controller. What now? |
| 211 | # |
| 212 | ssh $SSHOPTS -t -i $PVTKEY2 $SSHUSER@$PUBIP 'sudo bash -xc '"'"'mkdir -p /opt/dcae; if [ -f /tmp/cfy-config.txt ]; then cp /tmp/cfy-config.txt /opt/dcae/config.txt && chmod 644 /opt/dcae/config.txt; fi'"'" |
| 213 | cd $WORKDIR |
| 214 | |
| 215 | # |
| 216 | # Check for and set up https certificate information |
| 217 | # |
| 218 | rm -f $BSDIR/cloudify-manager-blueprints-3.4/resources/ssl/server.key $BSDIR/cloudify-manager-blueprints-3.4/resources/ssl/server.crt |
| 219 | ssh -t $SSHOPTS -i $PVTKEY2 $SSHUSER@$PUBIP 'sudo bash -xc "openssl pkcs12 -in /opt/app/dcae-certificate/certificate.pkcs12 -passin file:/opt/app/dcae-certificate/.password -nodes -chain"' | awk 'BEGIN{x="/dev/null";}/-----BEGIN CERTIFICATE-----/{x="'$BSDIR'/cloudify-manager-blueprints-3.4/resources/ssl/server.crt";}/-----BEGIN PRIVATE KEY-----/{x="'$BSDIR'/cloudify-manager-blueprints-3.4/resources/ssl/server.key";}{print >x;}/-----END /{x="/dev/null";}' |
| 220 | USESSL=false |
| 221 | if [ -f $BSDIR/cloudify-manager-blueprints-3.4/resources/ssl/server.key -a -f $BSDIR/cloudify-manager-blueprints-3.4/resources/ssl/server.crt ] |
| 222 | then |
| 223 | USESSL=true |
| 224 | fi |
| 225 | # |
| 226 | # Set up configuration for the bootstrap |
| 227 | # |
| 228 | export CLOUDIFY_USERNAME=admin CLOUDIFY_PASSWORD=encc0fba9f6d618a1a51935b42342b17658 |
| 229 | cd $BSDIR/cloudify-manager-blueprints-3.4 |
| 230 | cp simple-manager-blueprint.yaml bootstrap-blueprint.yaml |
| 231 | ed bootstrap-blueprint.yaml <<'!EOF' |
| 232 | /^node_types:/-1a |
| 233 | plugin_resources: |
| 234 | description: > |
| 235 | Holds any archives that should be uploaded to the manager. |
| 236 | default: [] |
| 237 | dsl_resources: |
| 238 | description: > |
| 239 | Holds a set of dsl required resources |
| 240 | default: [] |
| 241 | . |
| 242 | /^ upload_resources:/a |
| 243 | plugin_resources: { get_input: plugin_resources } |
| 244 | . |
| 245 | w |
| 246 | q |
| 247 | !EOF |
| 248 | |
| 249 | sed <simple-manager-blueprint-inputs.yaml >bootstrap-inputs.yaml \ |
| 250 | -e "s;.*public_ip: .*;public_ip: '$PUBIP';" \ |
| 251 | -e "s;.*private_ip: .*;private_ip: '$PVTIP';" \ |
| 252 | -e "s;.*ssh_user: .*;ssh_user: '$SSHUSER';" \ |
| 253 | -e "s;.*ssh_key_filename: .*;ssh_key_filename: '$PVTKEY2';" \ |
| 254 | -e "s;.*elasticsearch_java_opts: .*;elasticsearch_java_opts: '-Des.cluster.name=$ESMAGIC';" \ |
| 255 | -e "/ssl_enabled: /s/.*/ssl_enabled: $USESSL/" \ |
| 256 | -e "/security_enabled: /s/.*/security_enabled: $USESSL/" \ |
| 257 | -e "/admin_password: /s/.*/admin_password: '$CLOUDIFY_PASSWORD'/" \ |
| 258 | -e "/admin_username: /s/.*/admin_username: '$CLOUDIFY_USERNAME'/" \ |
| 259 | -e "s;.*manager_resources_package: .*;manager_resources_package: 'http://169.254.169.254/nosuchthing/$MRPFILE';" \ |
| 260 | -e "s;.*ignore_bootstrap_validations: .*;ignore_bootstrap_validations: true;" \ |
| 261 | |
| 262 | # Add plugin resources |
Jack Lucas | 1e353cb | 2017-10-11 21:10:08 +0000 | [diff] [blame] | 263 | # TODO Maintain plugin list as updates/additions occur |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 264 | cat >>bootstrap-inputs.yaml <<'!EOF' |
| 265 | plugin_resources: |
| 266 | - 'http://repository.cloudifysource.org/org/cloudify3/wagons/cloudify-openstack-plugin/1.4/cloudify_openstack_plugin-1.4-py27-none-linux_x86_64-centos-Core.wgn' |
| 267 | - 'http://repository.cloudifysource.org/org/cloudify3/wagons/cloudify-fabric-plugin/1.4.1/cloudify_fabric_plugin-1.4.1-py27-none-linux_x86_64-centos-Core.wgn' |
| 268 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/plugins/dnsdesig-1.0.0-py27-none-any.wgn' |
| 269 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/plugins/sshkeyshare-1.0.0-py27-none-any.wgn' |
Jack Lucas | 2574502 | 2017-10-20 18:39:00 +0000 | [diff] [blame] | 270 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/plugins/pgaas-1.0.0-py27-none-any.wgn' |
Jack Lucas | 1e353cb | 2017-10-11 21:10:08 +0000 | [diff] [blame] | 271 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/plugins/cdapcloudify/cdapcloudify-14.2.5-py27-none-any.wgn' |
| 272 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/plugins/dcaepolicyplugin/dcaepolicyplugin-1.0.0-py27-none-any.wgn' |
| 273 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/plugins/dockerplugin/dockerplugin-2.4.0-py27-none-any.wgn' |
| 274 | - '{{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_plugins_releases }}/plugins/relationshipplugin/relationshipplugin-1.0.0-py27-none-any.wgn' |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 275 | !EOF |
| 276 | # |
| 277 | # And away we go |
| 278 | # |
| 279 | cfy init -r |
| 280 | cfy bootstrap --install-plugins -p bootstrap-blueprint.yaml -i bootstrap-inputs.yaml |
| 281 | rm -f resources/ssl/server.key |
| 282 | |
| 283 | # Install Consul VM via a blueprint |
| 284 | cd $STARTDIR |
| 285 | mkdir consul |
| 286 | cd consul |
| 287 | cfy init -r |
| 288 | cfy use -t ${PUBIP} |
| 289 | echo "Deploying Consul VM" |
| 290 | |
| 291 | set +e |
Lusheng Ji | 557c2cd | 2017-10-25 13:36:54 -0400 | [diff] [blame] | 292 | if wget -O /tmp/consul_cluster.yaml {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2_platform_blueprints_releases }}/blueprints/consul_cluster.yaml; then |
| 293 | mv -f /tmp/consul_cluster.yaml ../blueprints/ |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 294 | echo "Succeeded in getting the newest consul_cluster.yaml" |
| 295 | else |
| 296 | echo "Failed to update consul_cluster.yaml, using default version" |
Lusheng Ji | 557c2cd | 2017-10-25 13:36:54 -0400 | [diff] [blame] | 297 | rm -f /tmp/consul_cluster.yaml |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 298 | fi |
| 299 | set -e |
| 300 | cfy install -p ../blueprints/consul_cluster.yaml -d consul -i ../${INPUTS} -i "datacenter=$LOCATION" |
| 301 | |
| 302 | # Get the floating IP for one member of the cluster |
| 303 | # Needed for instructing the Consul agent on CM host to join the cluster |
| 304 | CONSULIP=$(cfy deployments outputs -d consul | grep -Po 'Value: \K.*') |
| 305 | echo Consul deployed at $CONSULIP |
| 306 | |
| 307 | # Wait for Consul API to come up |
| 308 | until curl http://$CONSULIP:8500/v1/agent/services |
| 309 | do |
| 310 | echo Waiting for Consul API |
| 311 | sleep 60 |
| 312 | done |
| 313 | |
| 314 | # Wait for a leader to be elected |
| 315 | until [[ "$(curl -Ss http://$CONSULIP:8500/v1/status/leader)" != '""' ]] |
| 316 | do |
| 317 | echo Waiting for leader |
| 318 | sleep 30 |
| 319 | done |
| 320 | |
| 321 | # Instruct the client-mode Consul agent running on the CM to join the cluster |
| 322 | curl http://$PUBIP:8500/v1/agent/join/$CONSULIP |
| 323 | |
| 324 | # Register Cloudify Manager in Consul via the local agent on CM host |
| 325 | |
| 326 | REGREQ=" |
| 327 | { |
| 328 | \"Name\" : \"cloudify_manager\", |
| 329 | \"ID\" : \"cloudify_manager\", |
| 330 | \"Tags\" : [\"http://${PUBIP}/api/v2.1\"], |
| 331 | \"Address\": \"${PUBIP}\", |
| 332 | \"Port\": 80, |
| 333 | \"Check\" : { |
| 334 | \"Name\" : \"cloudify_manager_health\", |
| 335 | \"Interval\" : \"300s\", |
| 336 | \"HTTP\" : \"http://${PUBIP}/api/v2.1/status\", |
| 337 | \"Status\" : \"passing\", |
| 338 | \"DeregisterCriticalServiceAfter\" : \"30m\" |
| 339 | } |
| 340 | } |
| 341 | " |
| 342 | |
| 343 | curl -X PUT -H 'Content-Type: application/json' --data-binary "$REGREQ" http://$PUBIP:8500/v1/agent/service/register |
| 344 | # Make Consul address available to plugins on Cloudify Manager |
| 345 | # TODO probably not necessary anymore |
| 346 | ENVINI=$(mktemp) |
| 347 | cat <<!EOF > $ENVINI |
| 348 | [$LOCATION] |
| 349 | CONSUL_HOST=$CONSULIP |
| 350 | CONFIG_BINDING_SERVICE=config_binding_service |
| 351 | !EOF |
| 352 | scp $SSHOPTS -i ../$PVTKEY $ENVINI $SSHUSER@$PUBIP:/tmp/env.ini |
| 353 | ssh -t $SSHOPTS -i ../$PVTKEY $SSHUSER@$PUBIP sudo mv /tmp/env.ini /opt/env.ini |
| 354 | rm $ENVINI |
| 355 | |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 356 | |
| 357 | ##### INSTALLATION OF PLATFORM COMPONENTS |
| 358 | |
| 359 | # Get component blueprints |
| 360 | wget -P ./blueprints/docker/ ${DOCKERBPURL} |
| 361 | wget -P ./blueprints/cbs/ ${CBSBPURL} |
Jack Lucas | 53322ff | 2017-11-01 19:25:06 +0000 | [diff] [blame] | 362 | wget -P ./blueprints/pg/ ${PGBPURL} |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 363 | wget -P ./blueprints/cdap/ ${CDAPBPURL} |
| 364 | wget -P ./blueprints/cdapbroker/ ${CDAPBROKERBPURL} |
| 365 | wget -P ./blueprints/inv/ ${INVBPURL} |
| 366 | wget -P ./blueprints/dh/ ${DHBPURL} |
| 367 | wget -P ./blueprints/ph/ ${PHBPURL} |
Jack Lucas | 53322ff | 2017-11-01 19:25:06 +0000 | [diff] [blame] | 368 | wget -P ./blueprints/ves/ ${VESBPURL} |
| 369 | wget -P ./blueprints/tca/ ${TCABPURL} |
| 370 | wget -P ./blueprints/hrules/ ${HRULESBPURL} |
| 371 | wget -P ./blueprints/hengine/ ${HENGINEBPURL} |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 372 | |
| 373 | |
| 374 | # Set up the credentials for access to the Docker registry |
| 375 | curl -X PUT -H "Content-Type: application/json" --data-binary '[{"username":"docker", "password":"docker", "registry": "nexus3.onap.org:10001"}]' http://${CONSULIP}:8500/v1/kv/docker_plugin/docker_logins |
| 376 | |
| 377 | # Install platform Docker host |
| 378 | # Note we're still in the "consul" directory, which is init'ed for talking to CM |
| 379 | |
| 380 | set +e |
| 381 | # Docker host for platform containers |
| 382 | cfy install -v -p ./blueprints/docker/${DOCKERBP} -b DockerBP -d DockerPlatform -i ../${INPUTS} -i "registered_dockerhost_name=platform_dockerhost" -i "registrator_image=onapdcae/registrator:v7" -i "location_id=${LOCATION}" -i "node_name=dokp00" -i "target_datacenter=${LOCATION}" |
| 383 | |
| 384 | # Docker host for service containers |
| 385 | cfy deployments create -b DockerBP -d DockerComponent -i ../${INPUTS} -i "registered_dockerhost_name=component_dockerhost" -i "location_id=${LOCATION}" -i "registrator_image=onapdcae/registrator:v7" -i "node_name=doks00" -i "target_datacenter=${LOCATION}" |
| 386 | cfy executions start -d DockerComponent -w install |
| 387 | |
| 388 | # wait for the extended platform VMs settle |
| 389 | #sleep 180 |
| 390 | |
| 391 | |
| 392 | # CDAP cluster |
Jack Lucas | aa8ed20 | 2017-11-01 20:00:55 +0000 | [diff] [blame] | 393 | cfy install -p ./blueprints/cdap/${CDAPBP} -b cdapbp7 -d cdap7 -i ../config/cdapinputs.yaml -i "location_id=${LOCATION}" |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 394 | |
| 395 | # config binding service |
| 396 | cfy install -p ./blueprints/cbs/${CBSBP} -b config_binding_service -d config_binding_service -i "location_id=${LOCATION}" |
| 397 | |
| 398 | |
Jack Lucas | 53322ff | 2017-11-01 19:25:06 +0000 | [diff] [blame] | 399 | # Postgres |
| 400 | cfy install -p ./blueprints/pg/${PGBP} -b pgaas -d pgaas -i ../${INPUTS} |
| 401 | |
| 402 | |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 403 | # Inventory |
| 404 | cfy install -p ./blueprints/inv/${INVBP} -b PlatformServicesInventory -d PlatformServicesInventory -i "location_id=${LOCATION}" -i ../config/invinputs.yaml |
| 405 | |
| 406 | |
| 407 | # Deployment Handler DH |
| 408 | cat >../dhinputs <<EOL |
| 409 | application_config: |
| 410 | cloudify: |
| 411 | protocol: "http" |
| 412 | inventory: |
| 413 | protocol: "http" |
| 414 | EOL |
| 415 | cfy install -p ./blueprints/dh/${DHBP} -b DeploymentHandlerBP -d DeploymentHandler -i "location_id=${LOCATION}" -i ../dhinputs |
| 416 | |
| 417 | |
| 418 | # Policy Handler PH |
| 419 | cfy install -p ./blueprints/ph/${PHBP} -b policy_handler_BP -d policy_handler -i 'policy_handler_image=nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.policy-handler:1.1-latest' -i "location_id=${LOCATION}" -i ../config/phinputs.yaml |
| 420 | |
| 421 | |
Jack Lucas | 53b024f | 2017-10-19 13:36:15 +0000 | [diff] [blame] | 422 | # Wait for the CDAP cluster to be registered in Consul |
| 423 | echo "Waiting for CDAP cluster to register" |
| 424 | until curl -Ss http://${CONSULIP}:8500/v1/catalog/service/cdap | grep cdap |
| 425 | do |
| 426 | echo -n . |
| 427 | sleep 30 |
| 428 | done |
| 429 | echo "CDAP cluster registered" |
| 430 | |
| 431 | |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 432 | # CDAP Broker |
Jack Lucas | 53b024f | 2017-10-19 13:36:15 +0000 | [diff] [blame] | 433 | cfy install -p ./blueprints/cdapbroker/${CDAPBROKERBP} -b cdapbroker -d cdapbroker -i "location_id=${LOCATION}" |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 434 | |
| 435 | |
Jack Lucas | 53322ff | 2017-11-01 19:25:06 +0000 | [diff] [blame] | 436 | # VES |
| 437 | cfy install -p ./blueprints/ves/${VESBP} -b ves -d ves -i ../config/vesinput.yaml |
| 438 | |
| 439 | |
| 440 | # TCA |
| 441 | cfy install -p ./blueprints/tca/${TCABP} -b tca -d tca -i ../config/tcainputs.yaml |
| 442 | |
| 443 | # Holmes |
| 444 | cfy install -p ./blueprints/hrules/${HRULESBP} -b hrules -d hrules -i ../config/hr-ip.yaml |
| 445 | cfy install -p ./blueprints/hengine/${HENGINEBP} -b hengine -d hengine -i ../config/he-ip.yaml |
| 446 | |
| 447 | |
Lusheng Ji | 10388fd | 2017-10-20 16:14:38 -0400 | [diff] [blame] | 448 | # write out IP addresses |
| 449 | echo "$CONSULIP" > "$STARTDIR"/config/runtime.ip.consul |
| 450 | echo "$PUBIP" > "$STARTDIR"/config/runtime.ip.cm |
| 451 | |
| 452 | |
Jack Lucas | a3ff376 | 2017-10-14 00:24:19 +0000 | [diff] [blame] | 453 | # Keep the container up |
Lusheng Ji | c37f51b | 2017-10-15 22:17:30 -0400 | [diff] [blame] | 454 | rm -f /tmp/ready_to_exit |
| 455 | while [ ! -e /tmp/ready_to_exit ] |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 456 | do |
Lusheng Ji | c37f51b | 2017-10-15 22:17:30 -0400 | [diff] [blame] | 457 | sleep 30 |
Lusheng Ji | c38ca2f | 2017-09-11 20:11:29 +0000 | [diff] [blame] | 458 | done |