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 | - "{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/dnsdesig/dns_types.yaml" |
| 31 | - "{{ ONAPTEMPLATE_RAWREPOURL_org_onap_ccsdk_platform_plugins_releases }}/type_files/sshkeyshare/sshkey_types.yaml" |
| 32 | |
| 33 | inputs: |
| 34 | centos7image_id: |
| 35 | type: string |
| 36 | ubuntu1604image_id: |
| 37 | type: string |
| 38 | flavor_id: |
| 39 | type: string |
| 40 | security_group: |
| 41 | type: string |
| 42 | public_net: |
| 43 | type: string |
| 44 | private_net: |
| 45 | type: string |
| 46 | openstack: {} |
| 47 | keypair: |
| 48 | type: string |
| 49 | location_prefix: |
| 50 | type: string |
| 51 | location_domain: |
| 52 | type: string |
| 53 | key_filename: |
| 54 | type: string |
| 55 | codesource_url: |
| 56 | type: string |
| 57 | codesource_version: |
| 58 | type: string |
| 59 | datacenter: |
| 60 | type: string |
| 61 | vm_init_cnsl_00: |
| 62 | type: string |
| 63 | default: |- |
| 64 | #!/bin/sh |
| 65 | set -x |
| 66 | DATACENTER= |
| 67 | vm_init_cnsl_01: |
| 68 | type: string |
| 69 | default: | |
| 70 | CONSULVER=0.8.3 |
| 71 | CONSULNAME=consul_${CONSULVER}_linux_amd64 |
| 72 | MYIP=`wget -qO- http://169.254.169.254/2009-04-04/meta-data/local-ipv4` |
| 73 | MYNAME=`hostname` |
| 74 | echo >>/etc/hosts |
| 75 | echo $MYIP $MYNAME >>/etc/hosts |
| 76 | mkdir -p /opt/consul/config /opt/consul/data /opt/consul/bin |
| 77 | |
| 78 | # Download Consul |
| 79 | apt-get update |
| 80 | apt-get install unzip |
| 81 | wget https://releases.hashicorp.com/consul/${CONSULVER}/${CONSULNAME}.zip |
| 82 | unzip -d /opt/consul/bin ${CONSULNAME}.zip |
| 83 | rm ${CONSULNAME}.zip |
| 84 | chmod +x /opt/consul/bin/consul |
| 85 | |
| 86 | # NOTE: Not using port 80 for http to avoid port collision of user facing services |
| 87 | # particularly for more large scale deployments of Consul. |
| 88 | cat <<EOF > /opt/consul/config/consul.json |
| 89 | { |
| 90 | "bind_addr" : "$MYIP", |
| 91 | "client_addr" : "0.0.0.0", |
| 92 | "bootstrap_expect" : 3, |
| 93 | "data_dir" : "/opt/consul/data", |
| 94 | "datacenter": "$DATACENTER", |
| 95 | "http_api_response_headers": { |
| 96 | "Access-Control-Allow-Origin" : "*" |
| 97 | }, |
| 98 | "server": true, |
| 99 | "ui": true, |
| 100 | "enable_syslog": true, |
| 101 | "log_level": "info", |
| 102 | "ports": { |
| 103 | "dns": 53 |
| 104 | } |
| 105 | } |
| 106 | EOF |
| 107 | cat <<EOF > /lib/systemd/system/consul.service |
| 108 | [Unit] |
| 109 | Description=Consul |
| 110 | Requires=network-online.target |
| 111 | After=network.target |
| 112 | [Service] |
| 113 | Type=simple |
| 114 | ExecStart=/opt/consul/bin/consul agent -config-dir=/opt/consul/config |
| 115 | ExecReload=/bin/kill -HUP \$MAINPID |
| 116 | [Install] |
| 117 | WantedBy=multi-user.target |
| 118 | EOF |
| 119 | systemctl enable consul |
| 120 | systemctl start consul |
| 121 | node_templates: |
| 122 | key_pair: |
| 123 | type: cloudify.openstack.nodes.KeyPair |
| 124 | properties: |
| 125 | private_key_path: { get_input: key_filename } |
| 126 | use_external_resource: True |
| 127 | resource_id: { get_input: keypair } |
| 128 | openstack_config: &open_conf |
| 129 | get_input: openstack |
| 130 | private_net: |
| 131 | type: cloudify.openstack.nodes.Network |
| 132 | properties: |
| 133 | use_external_resource: True |
| 134 | resource_id: { get_input: private_net } |
| 135 | openstack_config: *open_conf |
| 136 | security_group: |
| 137 | type: cloudify.openstack.nodes.SecurityGroup |
| 138 | properties: |
| 139 | use_external_resource: True |
| 140 | resource_id: { get_input: security_group } |
| 141 | openstack_config: *open_conf |
| 142 | fixedip_cnsl00: |
| 143 | type: cloudify.openstack.nodes.Port |
| 144 | properties: |
| 145 | port: |
| 146 | extra_dhcp_opts: |
| 147 | - opt_name: 'domain-name' |
| 148 | opt_value: { get_input: location_domain } |
| 149 | openstack_config: *open_conf |
| 150 | relationships: |
| 151 | - type: cloudify.relationships.contained_in |
| 152 | target: private_net |
| 153 | floatingip_cnsl00: |
| 154 | type: cloudify.openstack.nodes.FloatingIP |
| 155 | properties: |
| 156 | openstack_config: *open_conf |
| 157 | interfaces: |
| 158 | cloudify.interfaces.lifecycle: |
| 159 | create: |
| 160 | inputs: |
| 161 | args: |
| 162 | floating_network_name: { get_input: public_net } |
| 163 | dns_cnsl00: |
| 164 | type: ccsdk.nodes.dns.arecord |
| 165 | properties: |
| 166 | fqdn: { concat: [ { get_input: location_prefix }, 'cnsl00.', { get_input: location_domain } ] } |
| 167 | openstack: *open_conf |
| 168 | interfaces: |
| 169 | cloudify.interfaces.lifecycle: |
| 170 | create: |
| 171 | inputs: |
| 172 | args: |
| 173 | ip_addresses: |
| 174 | - { get_attribute: [ floatingip_cnsl00, floating_ip_address ] } |
| 175 | relationships: |
| 176 | - type: cloudify.relationships.depends_on |
| 177 | target: floatingip_cnsl00 |
| 178 | host_cnsl00: |
| 179 | type: cloudify.openstack.nodes.Server |
| 180 | properties: |
| 181 | install_agent: false |
| 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 |
| 186 | interfaces: |
| 187 | cloudify.interfaces.lifecycle: |
| 188 | create: |
| 189 | inputs: |
| 190 | args: |
| 191 | name: { concat: [ { get_input: location_prefix }, 'cnsl00' ] } |
| 192 | userdata: |
| 193 | concat: |
| 194 | - { get_input: vm_init_cnsl_00 } |
| 195 | - { get_input: datacenter } |
| 196 | - |+ |
| 197 | |
| 198 | - { get_input: vm_init_cnsl_01 } |
| 199 | - concat: |
| 200 | - 'until /opt/consul/bin/consul join ' |
| 201 | - { get_attribute: [host_cnsl01, ip] } |
Lusheng Ji | dae872d | 2017-10-19 00:14:58 -0400 | [diff] [blame] | 202 | - '; do sleep 5; done; ' |
| 203 | - concat: |
| 204 | - 'until /opt/consul/bin/consul join ' |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 205 | - { get_attribute: [host_cnsl02, ip]} |
Lusheng Ji | dae872d | 2017-10-19 00:14:58 -0400 | [diff] [blame] | 206 | - '; do sleep 5; done' |
Lusheng Ji | 4365861 | 2017-09-08 19:12:45 +0000 | [diff] [blame] | 207 | |
| 208 | relationships: |
| 209 | - type: cloudify.openstack.server_connected_to_port |
| 210 | target: fixedip_cnsl00 |
| 211 | - type: cloudify.openstack.server_connected_to_security_group |
| 212 | target: security_group |
| 213 | - type: cloudify.openstack.server_connected_to_floating_ip |
| 214 | target: floatingip_cnsl00 |
| 215 | - type: cloudify.openstack.server_connected_to_keypair |
| 216 | target: key_pair |
| 217 | - type: cloudify.relationships.depends_on |
| 218 | target: dns_cnsl00 |
| 219 | - type: cloudify.relationships.depends_on |
| 220 | target: host_cnsl01 |
| 221 | - type: cloudify.relationships.depends_on |
| 222 | target: host_cnsl02 |
| 223 | fixedip_cnsl01: |
| 224 | type: cloudify.openstack.nodes.Port |
| 225 | properties: |
| 226 | port: |
| 227 | extra_dhcp_opts: |
| 228 | - opt_name: 'domain-name' |
| 229 | opt_value: { get_input: location_domain } |
| 230 | openstack_config: *open_conf |
| 231 | relationships: |
| 232 | - type: cloudify.relationships.contained_in |
| 233 | target: private_net |
| 234 | floatingip_cnsl01: |
| 235 | type: cloudify.openstack.nodes.FloatingIP |
| 236 | properties: |
| 237 | openstack_config: *open_conf |
| 238 | interfaces: |
| 239 | cloudify.interfaces.lifecycle: |
| 240 | create: |
| 241 | inputs: |
| 242 | args: |
| 243 | floating_network_name: { get_input: public_net } |
| 244 | dns_cnsl01: |
| 245 | type: ccsdk.nodes.dns.arecord |
| 246 | properties: |
| 247 | fqdn: { concat: [ { get_input: location_prefix }, 'cnsl01.', { get_input: location_domain } ] } |
| 248 | openstack: *open_conf |
| 249 | interfaces: |
| 250 | cloudify.interfaces.lifecycle: |
| 251 | create: |
| 252 | inputs: |
| 253 | args: |
| 254 | ip_addresses: |
| 255 | - { get_attribute: [ floatingip_cnsl01, floating_ip_address ] } |
| 256 | relationships: |
| 257 | - type: cloudify.relationships.depends_on |
| 258 | target: floatingip_cnsl01 |
| 259 | host_cnsl01: |
| 260 | type: cloudify.openstack.nodes.Server |
| 261 | properties: |
| 262 | install_agent: false |
| 263 | image: { get_input: ubuntu1604image_id } |
| 264 | flavor: { get_input: flavor_id } |
| 265 | management_network_name: { get_input: private_net } |
| 266 | openstack_config: *open_conf |
| 267 | interfaces: |
| 268 | cloudify.interfaces.lifecycle: |
| 269 | create: |
| 270 | inputs: |
| 271 | args: |
| 272 | name: { concat: [ { get_input: location_prefix }, 'cnsl01' ] } |
| 273 | userdata: |
| 274 | concat: |
| 275 | - { get_input: vm_init_cnsl_00 } |
| 276 | - { get_input: datacenter } |
| 277 | - |+ |
| 278 | |
| 279 | - { get_input: vm_init_cnsl_01 } |
| 280 | relationships: |
| 281 | - type: cloudify.openstack.server_connected_to_port |
| 282 | target: fixedip_cnsl01 |
| 283 | - type: cloudify.openstack.server_connected_to_security_group |
| 284 | target: security_group |
| 285 | - type: cloudify.openstack.server_connected_to_floating_ip |
| 286 | target: floatingip_cnsl01 |
| 287 | - type: cloudify.openstack.server_connected_to_keypair |
| 288 | target: key_pair |
| 289 | - type: cloudify.relationships.depends_on |
| 290 | target: dns_cnsl01 |
| 291 | fixedip_cnsl02: |
| 292 | type: cloudify.openstack.nodes.Port |
| 293 | properties: |
| 294 | port: |
| 295 | extra_dhcp_opts: |
| 296 | - opt_name: 'domain-name' |
| 297 | opt_value: { get_input: location_domain } |
| 298 | openstack_config: *open_conf |
| 299 | relationships: |
| 300 | - type: cloudify.relationships.contained_in |
| 301 | target: private_net |
| 302 | floatingip_cnsl02: |
| 303 | type: cloudify.openstack.nodes.FloatingIP |
| 304 | properties: |
| 305 | openstack_config: *open_conf |
| 306 | interfaces: |
| 307 | cloudify.interfaces.lifecycle: |
| 308 | create: |
| 309 | inputs: |
| 310 | args: |
| 311 | floating_network_name: { get_input: public_net } |
| 312 | dns_cnsl02: |
| 313 | type: ccsdk.nodes.dns.arecord |
| 314 | properties: |
| 315 | fqdn: { concat: [ { get_input: location_prefix }, 'cnsl02.', { get_input: location_domain } ] } |
| 316 | openstack: *open_conf |
| 317 | interfaces: |
| 318 | cloudify.interfaces.lifecycle: |
| 319 | create: |
| 320 | inputs: |
| 321 | args: |
| 322 | ip_addresses: |
| 323 | - { get_attribute: [ floatingip_cnsl02, floating_ip_address ] } |
| 324 | relationships: |
| 325 | - type: cloudify.relationships.depends_on |
| 326 | target: floatingip_cnsl02 |
| 327 | dns_cluster: |
| 328 | type: ccsdk.nodes.dns.arecord |
| 329 | properties: |
| 330 | fqdn: { concat: [ 'dcae-cnsl.', { get_input: location_domain } ] } |
| 331 | openstack: *open_conf |
| 332 | interfaces: |
| 333 | cloudify.interfaces.lifecycle: |
| 334 | create: |
| 335 | inputs: |
| 336 | args: |
| 337 | ip_addresses: |
| 338 | - { get_attribute: [ floatingip_cnsl00, floating_ip_address ] } |
| 339 | - { get_attribute: [ floatingip_cnsl01, floating_ip_address ] } |
| 340 | - { get_attribute: [ floatingip_cnsl02, floating_ip_address ] } |
| 341 | |
| 342 | relationships: |
| 343 | - type: cloudify.relationships.depends_on |
| 344 | target: floatingip_cnsl00 |
| 345 | - type: cloudify.relationships.depends_on |
| 346 | target: floatingip_cnsl01 |
| 347 | - type: cloudify.relationships.depends_on |
| 348 | target: floatingip_cnsl02 |
| 349 | host_cnsl02: |
| 350 | type: cloudify.openstack.nodes.Server |
| 351 | properties: |
| 352 | install_agent: false |
| 353 | image: { get_input: ubuntu1604image_id } |
| 354 | flavor: { get_input: flavor_id } |
| 355 | management_network_name: { get_input: private_net } |
| 356 | openstack_config: *open_conf |
| 357 | interfaces: |
| 358 | cloudify.interfaces.lifecycle: |
| 359 | create: |
| 360 | inputs: |
| 361 | args: |
| 362 | name: { concat: [ { get_input: location_prefix }, 'cnsl02' ] } |
| 363 | userdata: |
| 364 | concat: |
| 365 | - { get_input: vm_init_cnsl_00 } |
| 366 | - { get_input: datacenter } |
| 367 | - |+ |
| 368 | |
| 369 | - { get_input: vm_init_cnsl_01 } |
| 370 | relationships: |
| 371 | - type: cloudify.openstack.server_connected_to_port |
| 372 | target: fixedip_cnsl02 |
| 373 | - type: cloudify.openstack.server_connected_to_security_group |
| 374 | target: security_group |
| 375 | - type: cloudify.openstack.server_connected_to_floating_ip |
| 376 | target: floatingip_cnsl02 |
| 377 | - type: cloudify.openstack.server_connected_to_keypair |
| 378 | target: key_pair |
| 379 | - type: cloudify.relationships.depends_on |
| 380 | target: dns_cnsl02 |
| 381 | |
| 382 | outputs: |
| 383 | public_ip: |
| 384 | value: { get_attribute: [floatingip_cnsl00, floating_ip_address] } |