Skip to content

Instantly share code, notes, and snippets.

@mcornea
Last active March 22, 2016 08:21
Show Gist options
  • Select an option

  • Save mcornea/d421d510d5220135152f to your computer and use it in GitHub Desktop.

Select an option

Save mcornea/d421d510d5220135152f to your computer and use it in GitHub Desktop.
single_instance_floatingip_format_volume.yaml
heat_template_version: 2013-05-23
description: >
A HOT template that creates a VM instance,assigns it
a floating ip and a volume and formats and mounts
the volume inside the VM
parameters:
image:
type: string
description: >
Name or ID of the image to use for the instance.
constraints:
- custom_constraint: glance.image
description: Must identify an image known to Glance
flavor:
type: string
description: Flavor for the instance to be created
default: m1.small
constraints:
- custom_constraint: nova.flavor
description: Must be a flavor known to Nova
key_name:
type: string
description: Name of an existing key pair to use for the instance
constraints:
- custom_constraint: nova.keypair
description: Must name a public key (pair) known to Nova
private_network:
type: string
label: Private network name or ID
description: Network to attach instance to.
default: tenant-net
public_network:
type: string
label: Public network name or ID
description: Public network with floating IP addresses.
default: public-net
vol_size:
type: number
description: The size of the Cinder volume
default: 1
resources:
server_security_group:
type: OS::Neutron::SecurityGroup
properties:
name: server_security_group
rules:
- protocol: tcp
port_range_min: 22
port_range_max: 22
my_instance_port:
type: OS::Neutron::Port
properties:
network: { get_param: private_network }
security_groups:
- { get_resource: server_security_group }
my_instance:
type: OS::Nova::Server
properties:
image: { get_param: image }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
networks:
- network: { get_param: private_network }
networks:
- port: { get_resource: my_instance_port }
user_data: |
#!/bin/bash
mkfs.xfs /dev/vdc
echo '/dev/vdc /mnt xfs defaults 1 1' >> /etc/fstab
mount -a
my_vol:
type: OS::Cinder::Volume
properties:
size: { get_param: vol_size }
vol_att:
type: OS::Cinder::VolumeAttachment
properties:
instance_uuid: { get_resource: my_instance }
volume_id: { get_resource: my_vol }
mountpoint: /dev/vdc
floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network: { get_param: public_network }
floating_ip_assoc:
type: OS::Neutron::FloatingIPAssociation
properties:
floatingip_id: { get_resource: floating_ip }
port_id: { get_resource: my_instance_port }
outputs:
server_ip:
value: { get_attr: [floating_ip, floating_ip_address] }
description: Instance IP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment