Fatih Degirmenci | 464b192 | 2019-06-23 10:20:54 +0000 | [diff] [blame] | 1 | # ============LICENSE_START======================================================= |
| 2 | # Copyright (C) 2019 The Nordix Foundation. All rights reserved. |
| 3 | # ================================================================================ |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | # SPDX-License-Identifier: Apache-2.0 |
| 17 | # ============LICENSE_END========================================================= |
| 18 | |
| 19 | heat_template_version: 2017-02-24 |
| 20 | |
Fatih Degirmenci | 8c6947b | 2019-07-28 12:54:43 +0000 | [diff] [blame] | 21 | description: Common template for instances to install cluster on |
Fatih Degirmenci | 464b192 | 2019-06-23 10:20:54 +0000 | [diff] [blame] | 22 | |
| 23 | parameters: |
| 24 | # parameters for instances |
| 25 | instance_name: |
| 26 | type: string |
| 27 | label: Name |
| 28 | description: Instance name |
| 29 | |
| 30 | image: |
| 31 | type: string |
| 32 | label: Image name or ID |
| 33 | description: Image to use for instances |
| 34 | |
| 35 | flavor: |
| 36 | type: string |
| 37 | label: Flavor |
| 38 | description: Flavor to use for instances |
| 39 | |
Fatih Degirmenci | 464b192 | 2019-06-23 10:20:54 +0000 | [diff] [blame] | 40 | keypair: |
| 41 | type: string |
| 42 | label: Key name |
Fatih Degirmenci | 8c6947b | 2019-07-28 12:54:43 +0000 | [diff] [blame] | 43 | description: Keypair to use for instances |
| 44 | |
| 45 | internal_security_group: |
| 46 | type: string |
| 47 | label: Internal Security Group |
| 48 | description: Security Group to place jumphost and cluster instances in |
Fatih Degirmenci | 464b192 | 2019-06-23 10:20:54 +0000 | [diff] [blame] | 49 | |
| 50 | private_network: |
| 51 | type: string |
| 52 | label: Private network name or ID |
| 53 | description: Network to attach instances to |
| 54 | |
| 55 | resources: |
| 56 | wait_condition: |
| 57 | type: OS::Heat::WaitCondition |
| 58 | properties: |
| 59 | handle: { get_resource: wait_handle } |
| 60 | count: 1 |
Fatih Degirmenci | 471e70c | 2019-10-15 10:04:56 +0200 | [diff] [blame^] | 61 | timeout: 1200 |
Fatih Degirmenci | 464b192 | 2019-06-23 10:20:54 +0000 | [diff] [blame] | 62 | |
| 63 | wait_handle: |
| 64 | type: OS::Heat::WaitConditionHandle |
| 65 | |
| 66 | root_login: |
| 67 | type: OS::Heat::CloudConfig |
| 68 | properties: |
| 69 | cloud_config: |
| 70 | disable_root: false |
| 71 | |
| 72 | boot_script: |
| 73 | type: OS::Heat::SoftwareConfig |
| 74 | properties: |
| 75 | group: ungrouped |
| 76 | config: |
| 77 | str_replace: |
| 78 | params: |
| 79 | wc_notify: { get_attr: ['wait_handle', 'curl_cli'] } |
| 80 | template: | |
| 81 | #!/bin/bash -ex |
| 82 | |
| 83 | echo "Running boot script" |
| 84 | |
| 85 | # we need python for ansible |
| 86 | sudo apt update |
| 87 | sudo apt install -y python python-dev |
| 88 | |
| 89 | # notify completion |
| 90 | wc_notify --data-binary '{"status": "SUCCESS"}' |
| 91 | |
| 92 | boot_config: |
| 93 | type: OS::Heat::MultipartMime |
| 94 | properties: |
| 95 | parts: |
| 96 | - config: {get_resource: root_login} |
| 97 | - config: {get_resource: boot_script} |
| 98 | |
Fatih Degirmenci | 8c6947b | 2019-07-28 12:54:43 +0000 | [diff] [blame] | 99 | port: |
| 100 | type: OS::Neutron::Port |
| 101 | properties: |
| 102 | network: { get_param: private_network } |
| 103 | replacement_policy: AUTO |
| 104 | security_groups: |
| 105 | - { get_param: internal_security_group } |
| 106 | |
Fatih Degirmenci | 464b192 | 2019-06-23 10:20:54 +0000 | [diff] [blame] | 107 | instance: |
| 108 | type: OS::Nova::Server |
| 109 | properties: |
| 110 | name: { get_param: instance_name } |
| 111 | image: { get_param: image } |
| 112 | flavor: { get_param: flavor } |
| 113 | key_name: { get_param: keypair } |
| 114 | networks: |
Fatih Degirmenci | 8c6947b | 2019-07-28 12:54:43 +0000 | [diff] [blame] | 115 | - port: { get_resource: port } |
Fatih Degirmenci | 464b192 | 2019-06-23 10:20:54 +0000 | [diff] [blame] | 116 | user_data_format: SOFTWARE_CONFIG |
| 117 | user_data: { get_resource: boot_config } |
| 118 | |
| 119 | outputs: |
| 120 | instance_ip: |
| 121 | value: {get_attr: [instance, first_address]} |
| 122 | |
| 123 | # vim: set ts=2 sw=2 expandtab: |