Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Install DCAE via Cloudify Manager |
| 3 | # Expects: |
| 4 | # CM address (IP or DNS) in CMADDR environment variable |
| 5 | # CM password in CMPASS environment variable (assumes user is "admin") |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 6 | # Consul address with port in CONSUL variable |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 7 | # Plugin wagon files in /wagons |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 8 | # Blueprints for components to be installed in /blueprints |
| 9 | # Input files for components to be installed in /inputs |
| 10 | # Configuration JSON files that need to be loaded into Consul in /dcae-configs |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 11 | |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 12 | set -ex |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 13 | |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 14 | CBS_REG='{"ID": "dcae-cbs0", "Name": "config_binding_service", "Address": "config-binding-service", "Port": 10000}' |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 15 | # Deploy components |
| 16 | # $1 -- name (for bp and deployment) |
| 17 | # $2 -- blueprint name |
| 18 | # $3 -- inputs file name |
| 19 | function deploy { |
| 20 | cfy install -b $1 -d $1 -i /inputs/$3 /blueprints/$2 |
| 21 | } |
| 22 | # Set up profile to access CMs |
| 23 | cfy profiles use -u admin -t default_tenant -p "${CMPASS}" "${CMADDR}" |
| 24 | |
| 25 | # Output status, for debugging purposes |
| 26 | cfy status |
| 27 | |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 28 | # Load configurations into Consul |
| 29 | for config in /dcae-configs/*.json |
| 30 | do |
| 31 | # The basename of the file is the Consul key |
| 32 | key=$(basename ${config} .json) |
| 33 | # Strip out comments, empty lines |
| 34 | egrep -v "^#|^$" ${config} > /tmp/dcae-upload |
| 35 | curl -v -X PUT -H "Content-Type: application/json" --data-binary @/tmp/dcae-upload ${CONSUL}/v1/kv/${key} |
| 36 | done |
| 37 | |
| 38 | # For backward compatibility, load config_binding_service into Consul as service |
| 39 | curl -v -X PUT -H "Content-Type: application/json" --data "${CBS_REG}" ${CONSUL}/v1/agent/service/register |
| 40 | |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 41 | # Load plugins onto CM |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 42 | # Allow "already loaded" error |
| 43 | # (If there are other problems, will |
| 44 | # be caught in deployments.) |
| 45 | set +e |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 46 | for wagon in /wagons/*.wgn |
| 47 | do |
| 48 | cfy plugins upload ${wagon} |
| 49 | done |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 50 | set -e |
Jack Lucas | 230ae89 | 2018-03-27 00:04:46 -0400 | [diff] [blame] | 51 | |
| 52 | # Deploy platform components |
| 53 | deploy config_binding_service k8s-config_binding_service.yaml k8s-config_binding_service-inputs.yaml |
| 54 | deploy inventory k8s-inventory.yaml k8s-inventory-inputs.yaml |
| 55 | deploy deployment_handler k8s-deployment_handler.yaml k8s-deployment_handler-inputs.yaml |
| 56 | deploy policy_handler k8s-policy_handler.yaml k8s-policy_handler-inputs.yaml |
| 57 | |
Jack Lucas | 53f3110 | 2018-04-02 20:55:04 +0000 | [diff] [blame] | 58 | # Display deployments, for debugging purposes |
| 59 | cfy deployments list |