Skip to content

Instantly share code, notes, and snippets.

Created March 13, 2016 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/aea0c2b2e5b46d3dd873 to your computer and use it in GitHub Desktop.
Save anonymous/aea0c2b2e5b46d3dd873 to your computer and use it in GitHub Desktop.
heat_template_version: 2015-10-15
description: The database service.
parameter_groups:
parameters:
flavor:
type: string
label: Flavor
description: The name of the flavor to deploy.
key:
type: string
label: Key Pair
description: The ID of the KeyPair to inject.
count:
type: string
label: Instance Count
description: Number of database instances.
router:
type: string
label: Router
description: The ID of the router to act as the default gateway.
zone_map:
type: json
label: Availability Zones Hash
description: Hash to lookup AZ based on index.
security_groups:
type: comma_delimited_list
label: Security Groups
description: List of security groups to attach to instances.
resources:
network:
type: OS::Neutron::Net
properties:
name: database-network
subnet:
type: OS::Neutron::Subnet
properties:
name: database-subnet
network: { get_resource: network }
ip_version: 4
cidr: 192.168.20.0/24
gateway_ip: 192.168.20.1
enable_dhcp: true
dns_nameservers:
- 8.8.8.8
allocation_pools:
- start: 192.168.20.10
end: 192.168.20.254
router_interface:
type: OS::Neutron::RouterInterface
properties:
subnet: { get_resource: subnet }
router_id: { get_param: router }
monitor:
type: OS::Neutron::HealthMonitor
properties:
delay: 1
type: TCP
max_retries: 10
timeout: 1
pool:
type: OS::Neutron::Pool
properties:
description: foobar
lb_method: LEAST_CONNECTIONS
monitors:
- { get_resource: monitor }
name: database-pool
protocol: TCP
subnet: { get_resource: subnet }
vip:
description: The VIP for database servers.
name: database-vip
protocol_port: 3306
session_persistence:
type: SOURCE_IP
subnet: { get_resource: subnet }
security_group:
type: OS::Neutron::SecurityGroup
properties:
description: Open all port required for database servers.
name: database-server-communication
rules:
- direction: ingress
ethertype: IPv4
port_range_max: 3306
port_range_min: 3306
protocol: tcp
remote_ip_prefix: 0.0.0.0/0
InstanceGroup:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: count }
resource_def:
type: instance.yaml
properties:
prefix: db
key: { get_param: key }
image: "Ubuntu Trusty 14.04 LTS"
flavor: m1.small
network: { get_attr: [network, name] }
zone_map: { get_param: zone_map }
idx: "%index%"
pool: { get_resource: pool }
# THIS WORKS. MEANS PARAM IS OF TYPE ARRAY
# security_groups: { get_param: security_groups }
# THIS WORKS. MEANS AN ARRAY OF RESOURCE TYPE IS EXPECTED
# security_groups: [{get_resource: security_group}]
# THIS WORKS. AN ARRAY OF MIXED STRING AND RESOURCE CAN BE JOINED THEN SPLIT.
# security_groups: { str_split: [',', list_join: [',', ['default','ssh', get_resource: security_group]]]}
# THIS WORKS. MEANS THE LIST_JOIN CAN JOIN MULTIPLE LISTS.
# security_groups: { str_split: [',', list_join: [',', ['default'],['ssh']]]}
security_groups: { str_split: [',', list_join: [',', get_param: security_groups, [get_attr: [security_group,name]]]] }
#security_groups: { str_split: [',', list_join: [',',get_param: security_groups,get_attr: [security_group, name]]] }
#security_groups: { str_split: [',', list_join: [',', get_param: security_groups, [get_resource: security_group]]] }
outputs:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment