Skip to content

Instantly share code, notes, and snippets.

@sandlbn
Created February 16, 2015 11:52
Show Gist options
  • Save sandlbn/ba2c3c9b9cd373a55f6b to your computer and use it in GitHub Desktop.
Save sandlbn/ba2c3c9b9cd373a55f6b to your computer and use it in GitHub Desktop.
heat_template_version: 2013-05-23
description: >
Creates a vm with access to the internet.
parameters:
#Server Parameters
image:
type: string
description: Name of image to use for servers
default: ubuntu1404
flavor:
type: string
description: Flavor to use for servers
default: m1.medium
key_name:
type: string
description: Name of SSH key
owner:
type: string
description: name of the VM owner
constraints:
- length: { min: 1, max: 15 }
- allowed_pattern: "[a-zA-Z]*"
#Private Net Parameters
private_net_id:
type: string
description: id of the private network
default: 5e6c3162-e69f-46c3-8e2d-06bf2a6df264
private_subnet_id:
type: string
description: id of the private subnet
default: 04da7186-d255-401b-b6db-214564942a48
#Public Net Parameters
public_net_id:
type: string
description: id of the public network
default: be6312a9-9406-482d-87f8-ded97b501397
public_subnet_id:
type: string
description: id of the public subnet
default: 502c242d-6f80-4cd1-9dd6-e0111a2c3197
resources:
# 1. Create Private net connection
server_port:
type: OS::Neutron::Port
properties:
network_id: { get_param: private_net_id }
fixed_ips:
- subnet_id: { get_param: private_subnet_id }
# 2. Create Public net connection
server_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: { get_param: public_net_id }
port_id: { get_resource: server_port }
# 3. Create VM and connect to networks
server:
type: OS::Nova::Server
properties:
name:
str_replace:
template: vm_owner
params:
owner: { get_param: owner}
image: { get_param: image }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: server_port }
user_data:
str_replace:
params:
owner: { get_param: owner }
key_name: { get_param: key_name }
template: |
#!/bin/bash
# Add required script here
outputs:
server_private_ip:
description: IP address of vm on the private network
value: { get_attr: [ server, first_address ] }
server_public_ip:
description: Floating IP address of the vm
value: { get_attr: [server_floating_ip, floating_ip_address ] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment