Tony Hansen | 749bc2d | 2017-10-03 02:51:42 +0000 | [diff] [blame] | 1 | # -*- indent-tabs-mode: nil -*- # vi: set expandtab: |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 2 | # |
| 3 | # ============LICENSE_START========================================== |
Tony Hansen | 749bc2d | 2017-10-03 02:51:42 +0000 | [diff] [blame] | 4 | # org.onap.dcae |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 5 | # =================================================================== |
| 6 | # Copyright © 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 |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 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============================================ |
| 20 | # |
| 21 | # ECOMP and OpenECOMP are trademarks |
| 22 | # and service marks of AT&T Intellectual Property. |
| 23 | # |
| 24 | |
| 25 | tosca_definitions_version: cloudify_dsl_1_3 |
| 26 | |
| 27 | imports: |
| 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 |
| 31 | - types/dns_types.yaml |
| 32 | - types/sshkey_types.yaml |
| 33 | |
| 34 | inputs: |
| 35 | centos7image_id: |
| 36 | type: string |
| 37 | ubuntu1604image_id: |
| 38 | type: string |
| 39 | flavor_id: |
| 40 | type: string |
| 41 | security_group: |
| 42 | type: string |
| 43 | public_net: |
| 44 | type: string |
| 45 | private_net: |
| 46 | type: string |
| 47 | openstack: {} |
| 48 | keypair: |
| 49 | type: string |
| 50 | location_prefix: |
| 51 | type: string |
| 52 | location_domain: |
| 53 | type: string |
| 54 | key_filename: |
| 55 | type: string |
| 56 | codesource_url: |
| 57 | type: string |
| 58 | codesource_version: |
| 59 | type: string |
| 60 | cname: |
| 61 | type: string |
| 62 | default: dcae-orcl |
| 63 | datacenter: |
| 64 | type: string |
| 65 | vm_init_clmg_00: |
| 66 | type: string |
| 67 | default: |- |
| 68 | #!/bin/sh |
| 69 | set -x |
| 70 | DATACENTER= |
| 71 | vm_init_clmg_01: |
| 72 | type: string |
| 73 | default: | |
| 74 | CONSULVER=0.8.3 |
| 75 | CONSULNAME=consul_${CONSULVER}_linux_amd64 |
| 76 | MYIP=`curl -Ss http://169.254.169.254/2009-04-04/meta-data/local-ipv4` |
| 77 | MYNAME=`hostname` |
Lusheng Ji | 9a3daed | 2017-10-25 12:13:28 -0400 | [diff] [blame] | 78 | if [ ! -z "$(echo $MYNAME |grep '.')" ]; then MYNAME="$(echo $MYNAME | cut -f1 -d '.')"; fi |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 79 | echo >>/etc/hosts |
| 80 | echo $MYIP $MYNAME >>/etc/hosts |
| 81 | mkdir -p /opt/consul/config /opt/consul/data /opt/consul/bin |
| 82 | yum install -y unzip |
| 83 | # Download Consul |
| 84 | curl -Ss https://releases.hashicorp.com/consul/${CONSULVER}/${CONSULNAME}.zip > ${CONSULNAME}.zip |
| 85 | unzip -d /opt/consul/bin ${CONSULNAME}.zip |
| 86 | rm ${CONSULNAME}.zip |
| 87 | chmod +x /opt/consul/bin/consul |
| 88 | cat <<EOF > /opt/consul/config/consul.json |
| 89 | { |
| 90 | "bind_addr" : "0.0.0.0", |
| 91 | "client_addr" : "0.0.0.0", |
| 92 | "data_dir" : "/opt/consul/data", |
| 93 | "datacenter": "$DATACENTER", |
| 94 | "rejoin_after_leave": true, |
| 95 | "http_api_response_headers": { |
| 96 | "Access-Control-Allow-Origin" : "*" |
| 97 | }, |
| 98 | "server": false, |
| 99 | "ui": false, |
| 100 | "enable_syslog": true, |
| 101 | "log_level": "info" |
| 102 | } |
| 103 | EOF |
| 104 | cat <<EOF > /lib/systemd/system/consul.service |
| 105 | [Unit] |
| 106 | Description=Consul |
| 107 | Requires=network-online.target |
| 108 | After=network.target |
| 109 | [Service] |
| 110 | Type=simple |
| 111 | ExecStart=/opt/consul/bin/consul agent -config-dir=/opt/consul/config |
| 112 | ExecReload=/bin/kill -HUP \$MAINPID |
| 113 | [Install] |
| 114 | WantedBy=multi-user.target |
| 115 | EOF |
| 116 | systemctl enable consul |
| 117 | systemctl start consul |
| 118 | yum install -y python-psycopg2 |
| 119 | |
| 120 | node_templates: |
| 121 | key_pair: |
| 122 | type: cloudify.openstack.nodes.KeyPair |
| 123 | properties: |
| 124 | private_key_path: { get_input: key_filename } |
| 125 | use_external_resource: True |
| 126 | resource_id: { get_input: keypair } |
| 127 | openstack_config: &open_conf |
| 128 | get_input: openstack |
| 129 | private_net: |
| 130 | type: cloudify.openstack.nodes.Network |
| 131 | properties: |
| 132 | use_external_resource: True |
| 133 | resource_id: { get_input: private_net } |
| 134 | openstack_config: *open_conf |
| 135 | security_group: |
| 136 | type: cloudify.openstack.nodes.SecurityGroup |
| 137 | properties: |
| 138 | use_external_resource: True |
| 139 | resource_id: { get_input: security_group } |
| 140 | openstack_config: *open_conf |
| 141 | fixedip_vm00: |
| 142 | type: cloudify.openstack.nodes.Port |
| 143 | properties: |
| 144 | port: |
| 145 | extra_dhcp_opts: |
| 146 | - opt_name: 'domain-name' |
| 147 | opt_value: { get_input: location_domain } |
| 148 | openstack_config: *open_conf |
| 149 | relationships: |
| 150 | - type: cloudify.relationships.contained_in |
| 151 | target: private_net |
| 152 | floatingip_vm00: |
| 153 | type: cloudify.openstack.nodes.FloatingIP |
| 154 | properties: |
| 155 | openstack_config: *open_conf |
| 156 | interfaces: |
| 157 | cloudify.interfaces.lifecycle: |
| 158 | create: |
| 159 | inputs: |
| 160 | args: |
| 161 | floating_network_name: { get_input: public_net } |
| 162 | dns_vm00: |
| 163 | type: ccsdk.nodes.dns.arecord |
| 164 | properties: |
| 165 | fqdn: { concat: [ { get_input: location_prefix }, 'orcl00.', { get_input: location_domain } ] } |
| 166 | openstack: *open_conf |
| 167 | interfaces: |
| 168 | cloudify.interfaces.lifecycle: |
| 169 | create: |
| 170 | inputs: |
| 171 | args: |
| 172 | ip_addresses: |
| 173 | - { get_attribute: [ floatingip_vm00, floating_ip_address ] } |
| 174 | relationships: |
| 175 | - type: cloudify.relationships.depends_on |
| 176 | target: floatingip_vm00 |
| 177 | dns_cm: |
| 178 | type: ccsdk.nodes.dns.arecord |
| 179 | properties: |
| 180 | fqdn: { concat: [ 'cloudify-manager-', { get_input: datacenter}, '.', { get_input: location_domain } ] } |
| 181 | openstack: *open_conf |
| 182 | interfaces: |
| 183 | cloudify.interfaces.lifecycle: |
| 184 | create: |
| 185 | inputs: |
| 186 | args: |
| 187 | ip_addresses: |
| 188 | - { get_attribute: [ floatingip_vm00, floating_ip_address ] } |
| 189 | relationships: |
| 190 | - type: cloudify.relationships.depends_on |
| 191 | target: floatingip_vm00 |
| 192 | dns_cname: |
| 193 | type: ccsdk.nodes.dns.cnamerecord |
| 194 | properties: |
| 195 | fqdn: { concat: [ { get_input: cname }, '.', { get_input: location_domain } ] } |
| 196 | openstack: *open_conf |
| 197 | interfaces: |
| 198 | cloudify.interfaces.lifecycle: |
| 199 | create: |
| 200 | inputs: |
| 201 | args: |
| 202 | cname: { get_property: [ dns_vm00, fqdn ] } |
| 203 | relationships: |
| 204 | - type: cloudify.relationships.depends_on |
| 205 | target: dns_vm00 |
| 206 | host_vm00: |
| 207 | type: cloudify.openstack.nodes.Server |
| 208 | properties: |
| 209 | install_agent: false |
| 210 | image: { get_input: centos7image_id } |
| 211 | flavor: { get_input: flavor_id } |
| 212 | management_network_name: { get_input: private_net } |
| 213 | openstack_config: *open_conf |
| 214 | interfaces: |
| 215 | cloudify.interfaces.lifecycle: |
| 216 | create: |
| 217 | inputs: |
| 218 | args: |
| 219 | name: { concat: [ { get_input: location_prefix }, 'orcl00' ] } |
| 220 | userdata: |
| 221 | concat: |
| 222 | - { get_input: vm_init_clmg_00 } |
| 223 | - { get_input: datacenter } |
| 224 | - |+ |
| 225 | |
| 226 | - { get_input: vm_init_clmg_01 } |
| 227 | relationships: |
| 228 | - type: cloudify.openstack.server_connected_to_port |
| 229 | target: fixedip_vm00 |
| 230 | - type: cloudify.openstack.server_connected_to_security_group |
| 231 | target: security_group |
| 232 | - type: cloudify.openstack.server_connected_to_floating_ip |
| 233 | target: floatingip_vm00 |
| 234 | - type: cloudify.openstack.server_connected_to_keypair |
| 235 | target: key_pair |
| 236 | - type: cloudify.relationships.depends_on |
| 237 | target: dns_vm00 |
| 238 | - type: cloudify.relationships.depends_on |
| 239 | target: dns_cm |
| 240 | |
| 241 | outputs: |
| 242 | public_ip: |
| 243 | value: { get_attribute: [floatingip_vm00, floating_ip_address] } |