Skip to content

Instantly share code, notes, and snippets.

@ualmtorres
Last active January 24, 2019 13:03
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 ualmtorres/8f1e7720deaa3aefa77678372e37d69e to your computer and use it in GitHub Desktop.
Save ualmtorres/8f1e7720deaa3aefa77678372e37d69e to your computer and use it in GitHub Desktop.
Heat template to build OpenStack basic infrastructure
heat_template_version: 2016-04-08
description: >
OpenStack Sample template.
This template creates virtual infrastructure for OpenStack instances. The basic infrastructure constists of two networks (management-net and tunnel-net) and three nodes: controller, networks and one compute node.
parameter_groups:
- label: Grupo de parámetros
description: Grupo de parámetros
parameters:
- controller_instance_type
- network_instance_type
- compute_instance_type
- image_id
- key_name
- network_name
- subnetwork_name
- management_net_cidr
- tunnel_net_cidr
parameters:
controller_instance_type:
label: Instance type for controller node
type: string
description: Instance type for controller node
constraints:
- custom_constraint: nova.flavor
network_instance_type:
label: Instance type for network node
type: string
description: Instance type for network node
constraints:
- custom_constraint: nova.flavor
compute_instance_type:
label: Instance type for computer node
type: string
description: Instance type for compute node
constraints:
- custom_constraint: nova.flavor
image_id:
label: Image to use for the instance
type: string
description: >
Name or ID of the image to use for the instance
constraints:
- custom_constraint: glance.image
key_name:
label: Keypair name
type: string
description: Name of a KeyPair to enable SSH access to the instance
constraints:
- custom_constraint: nova.keypair
network_name:
label: OpenStack network with Internet connection
type: string
description: >
Network with Internet connection
constraints:
- custom_constraint: neutron.network
subnetwork_name:
label: Subnet of the network with Internet connection
type: string
description: >
Subnet of the network with Intenet connection
default: "mtorres-subnet"
management_net_cidr:
label: CIDR of the management network
type: string
description: >
Management network CIDR
default: "10.0.0.0/24"
tunnel_net_cidr:
label: CIDR of the tunnel network
type: string
description: >
Tunnel network CIDR
default: "10.0.1.0/24"
resources:
mamagement_net:
type: OS::Neutron::Net
properties:
name: management-net
management_subnet:
type: OS::Neutron::Subnet
properties:
network_id: {get_resource: mamagement_net}
cidr: { get_param: management_net_cidr }
dns_nameservers: [ 150.214.156.2, 8.8.8.8 ]
tunnel_net:
type: OS::Neutron::Net
properties:
name: tunnel-net
tunnel_subnet:
type: OS::Neutron::Subnet
properties:
network_id: {get_resource: tunnel_net}
cidr: { get_param: tunnel_net_cidr }
dns_nameservers: [ 150.214.156.2, 8.8.8.8 ]
external_controller_port:
type: OS::Neutron::Port
properties:
network_id: { get_param: network_name }
fixed_ips:
- subnet_id: { get_param: subnetwork_name }
controller_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: lowcost-net
port_id: { get_resource: external_controller_port }
controller_management_port:
type: OS::Neutron::Port
properties:
network: { get_resource: mamagement_net }
fixed_ips:
- subnet_id: { get_resource: management_subnet }
controller_tunnel_port:
type: OS::Neutron::Port
properties:
network: { get_resource: tunnel_net }
fixed_ips:
- subnet_id: { get_resource: tunnel_subnet }
controller:
type: OS::Nova::Server
properties:
name: virtual-control
image: { get_param: image_id }
flavor: { get_param: controller_instance_type }
key_name: { get_param: key_name }
networks:
# - network: { get_param: network_name }
- port: { get_resource: external_controller_port }
- port: { get_resource: controller_management_port }
- port: { get_resource: controller_tunnel_port }
external_network_port:
type: OS::Neutron::Port
properties:
network_id: { get_param: network_name }
fixed_ips:
- subnet_id: { get_param: subnetwork_name }
network_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: lowcost-net
port_id: { get_resource: external_network_port }
network_management_port:
type: OS::Neutron::Port
properties:
network: { get_resource: mamagement_net }
fixed_ips:
- subnet_id: { get_resource: management_subnet }
network_tunnel_port:
type: OS::Neutron::Port
properties:
network: { get_resource: tunnel_net }
fixed_ips:
- subnet_id: { get_resource: tunnel_subnet }
network:
type: OS::Nova::Server
properties:
name: virtual-network
image: { get_param: image_id }
flavor: { get_param: network_instance_type }
key_name: { get_param: key_name }
networks:
# - network: { get_param: network_name }
- port: { get_resource: external_network_port }
- port: { get_resource: network_management_port }
- port: { get_resource: network_tunnel_port }
external_compute_port:
type: OS::Neutron::Port
properties:
network_id: { get_param: network_name }
fixed_ips:
- subnet_id: { get_param: subnetwork_name }
compute_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: lowcost-net
port_id: { get_resource: external_compute_port }
compute_management_port:
type: OS::Neutron::Port
properties:
network: { get_resource: mamagement_net }
fixed_ips:
- subnet_id: { get_resource: management_subnet }
compute_tunnel_port:
type: OS::Neutron::Port
properties:
network: { get_resource: tunnel_net }
fixed_ips:
- subnet_id: { get_resource: tunnel_subnet }
compute:
type: OS::Nova::Server
properties:
name: virtual-compute
image: { get_param: image_id }
flavor: { get_param: compute_instance_type }
key_name: { get_param: key_name }
networks:
# - network: { get_param: network_name }
- port: { get_resource: external_compute_port }
- port: { get_resource: compute_management_port }
- port: { get_resource: compute_tunnel_port }
resources:
mamagement_net:
type: OS::Neutron::Net
properties:
name: management-net
management_subnet:
type: OS::Neutron::Subnet
properties:
network_id: {get_resource: mamagement_net}
cidr: { get_param: management_net_cidr }
dns_nameservers: [ 150.214.156.2, 8.8.8.8 ]
tunnel_net:
type: OS::Neutron::Net
properties:
name: tunnel-net
tunnel_subnet:
type: OS::Neutron::Subnet
properties:
network_id: {get_resource: tunnel_net}
cidr: { get_param: tunnel_net_cidr }
dns_nameservers: [ 150.214.156.2, 8.8.8.8 ]
external_controller_port:
type: OS::Neutron::Port
properties:
network_id: { get_param: network_name }
fixed_ips:
- subnet_id: { get_param: subnetwork_name }
controller_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: lowcost-net
port_id: { get_resource: external_controller_port }
controller_management_port:
type: OS::Neutron::Port
properties:
network: { get_resource: mamagement_net }
fixed_ips:
- subnet_id: { get_resource: management_subnet }
controller_tunnel_port:
type: OS::Neutron::Port
properties:
network: { get_resource: tunnel_net }
fixed_ips:
- subnet_id: { get_resource: tunnel_subnet }
controller:
type: OS::Nova::Server
properties:
name: virtual-control
image: { get_param: image_id }
flavor: { get_param: controller_instance_type }
key_name: { get_param: key_name }
networks:
# - network: { get_param: network_name }
- port: { get_resource: external_controller_port }
- port: { get_resource: controller_management_port }
- port: { get_resource: controller_tunnel_port }
external_network_port:
type: OS::Neutron::Port
properties:
network_id: { get_param: network_name }
fixed_ips:
- subnet_id: { get_param: subnetwork_name }
network_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: lowcost-net
port_id: { get_resource: external_network_port }
network_management_port:
type: OS::Neutron::Port
properties:
network: { get_resource: mamagement_net }
fixed_ips:
- subnet_id: { get_resource: management_subnet }
network_tunnel_port:
type: OS::Neutron::Port
properties:
network: { get_resource: tunnel_net }
fixed_ips:
- subnet_id: { get_resource: tunnel_subnet }
network:
type: OS::Nova::Server
properties:
name: virtual-network
image: { get_param: image_id }
flavor: { get_param: network_instance_type }
key_name: { get_param: key_name }
networks:
# - network: { get_param: network_name }
- port: { get_resource: external_network_port }
- port: { get_resource: network_management_port }
- port: { get_resource: network_tunnel_port }
external_compute_port:
type: OS::Neutron::Port
properties:
network_id: { get_param: network_name }
fixed_ips:
- subnet_id: { get_param: subnetwork_name }
compute_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: lowcost-net
port_id: { get_resource: external_compute_port }
compute_management_port:
type: OS::Neutron::Port
properties:
network: { get_resource: mamagement_net }
fixed_ips:
- subnet_id: { get_resource: management_subnet }
compute_tunnel_port:
type: OS::Neutron::Port
properties:
network: { get_resource: tunnel_net }
fixed_ips:
- subnet_id: { get_resource: tunnel_subnet }
compute:
type: OS::Nova::Server
properties:
name: virtual-compute
image: { get_param: image_id }
flavor: { get_param: compute_instance_type }
key_name: { get_param: key_name }
networks:
# - network: { get_param: network_name }
- port: { get_resource: external_compute_port }
- port: { get_resource: compute_management_port }
- port: { get_resource: compute_tunnel_port }
outputs:
controller_instance_name:
description: Name of the controller instance
value: { get_attr: [controller, name] }
controller_instance_ip:
description: Floating IP address of the controller instance
value: { get_attr: [controller_floating_ip, floating_ip_address] }
network_instance_name:
description: Name of the network instance
value: { get_attr: [network, name] }
network_instance_ip:
description: Floating IP address of the network instance
value: { get_attr: [network_floating_ip, floating_ip_address] }
compute_instance_name:
description: Name of the compute instance
value: { get_attr: [compute, name] }
compute_instance_ip:
description: Floating IP address of the compute instance
value: { get_attr: [compute_floating_ip, floating_ip_address] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment