#jinja2: lstrip_blocks: "True"
|
---
|
heat_template_version: 2018-03-02
|
|
description: Nested HOT for creating instances, ports, & floating IPs. This template relies is called by a top level template that is resposible for common resources such as network, router, etc.
|
|
parameters:
|
|
network_private:
|
type: string
|
description: The name of the network created by the top level HOT.
|
|
security_groups:
|
type: json
|
description: The list of security groups created by the top level HOT. Passed as a list or string?
|
|
provider_network:
|
type: string
|
description: The provider network where floating IPs will be provisioned from.
|
|
instance_name:
|
type: string
|
description: The instance name is passed from the top level HOT. It should be appended with an index value if there will be more than one of this type of instance deployed.
|
|
instance_image:
|
type: string
|
|
instance_flavor:
|
type: string
|
|
instance_metadata:
|
type: json
|
description: Metadata in OpenStack is the equivilent to tags in a cloud provider such as AWS
|
|
instance_fip:
|
type: boolean
|
description: When passed from top level HOT, this will determine whether the FIP and FIP association resources are created based on condition.
|
|
volume_size:
|
type: number
|
description: The size in GB of the volume being created from an image.
|
|
key_name:
|
type: string
|
description: The SSH key that will be added to the instance.
|
|
{% for instance in instances %}
|
{% if instance.volumes is defined %}
|
{% for volume in instance.volumes %}
|
{% set loopvolume = loop %}
|
{% for myinstanceindex in range(instance.count|int) %}
|
{% set iname = instance.name if instance.count == 1 else instance.name + loop.index0 %}
|
{% set vname = ["volume", iname, loopvolume.index] | join('_') %}
|
add_vol_{{ vname }}:
|
type: string
|
{% endfor %}
|
{% endfor %}
|
{% endif %}
|
{% endfor %}
|
|
conditions:
|
|
create_fip:
|
get_param: instance_fip
|
|
resources:
|
|
port:
|
type: OS::Neutron::Port
|
properties:
|
network: { get_param: network_private }
|
security_groups: { get_param: security_groups }
|
|
fip:
|
type: OS::Neutron::FloatingIP
|
condition: create_fip
|
properties:
|
floating_network: { get_param: provider_network }
|
|
fip_association:
|
type: OS::Neutron::FloatingIPAssociation
|
condition: create_fip
|
properties:
|
floatingip_id: { get_resource: fip }
|
port_id: { get_resource: port }
|
|
instance:
|
type: OS::Nova::Server
|
properties:
|
name: { get_param: instance_name }
|
flavor: { get_param: instance_flavor }
|
key_name: { get_param: key_name }
|
block_device_mapping_v2:
|
- image: { get_param: instance_image }
|
delete_on_termination: true
|
volume_size: { get_param: volume_size }
|
boot_index: 0
|
{% for instance in instances %}
|
{% if instance.volumes is defined %}
|
{% for volume in instance.volumes %}
|
{% set loopvolume = loop %}
|
{% for myinstanceindex in range(instance.count|int) %}
|
{% set iname = instance.name if instance.count == 1 else instance.name + loop.index0 %}
|
{% set vname = ["volume", iname, loopvolume.index] | join('_') %}
|
- volume_id: { get_param: add_vol_{{ vname }} }
|
boot_index: -1
|
{% endfor %}
|
{% endfor %}
|
{% endif %}
|
{% endfor %}
|
user_data: |
|
#cloud-config
|
ssh_authorized_keys: {{ all_ssh_authorized_keys | to_json }}
|
user_data_format: RAW
|
networks:
|
- port: { get_resource: port }
|
metadata:
|
get_param: instance_metadata
|