Showing posts with label Openstack. Show all posts
Showing posts with label Openstack. Show all posts

Openstack Heat template with anti affinity group example

Example of using heat template which allows us to keep virtual machines on different physical hosts.

Example heat template

######

heat_template_version: 2014-10-16

description: Haproxy hosts

parameters:
service-flavour:
type: string
default: rhel6-cloud.1.2
image:
type: string
default: redhat6
key_name:
type: string
default: mykey

resources:
haproxy-svrgrp:
type: OS::Nova::ServerGroup
properties:
name: haproxy-svrgrp
policies: [ 'anti-affinity' ]

haproxy-01:
type: OS::Nova::Server
properties:
name: haproxy-01
flavor: { get_param: service-flavour }
image: { get_param: image }
key_name: { get_param: key_name }
admin_user: cloud-user
networks:
- port: { get_resource: haproxy-01-port }
scheduler_hints:
group: haproxy-svrgrp

haproxy-02:
type: OS::Nova::Server
properties:
name: haproxy-02
flavor: { get_param: service-flavour }
image: { get_param: image }
key_name: { get_param: key_name }
admin_user: cloud-user
networks:
- port: { get_resource: haproxy-02-port }
scheduler_hints:
group: haproxy-svrgrp


######


Further readings

http://docs.openstack.org/developer/heat/template_guide/hot_spec.html

http://docs.openstack.org/icehouse/config-reference/content/section_compute-scheduler.html