w-ser

lvhailong / 2023-08-09 / 原文

heat_template_version: queens
description: HeatStack

parameters:
image_name:
type: string
default: web
description: Image used for web server
constraints:
- custom_constraint: glance.image
instance_name:
type: string
default: HeatStack
description: Name for the web server
key_name:
type: string
default: webkey
description: SSH key to connect to the servers
constraints:
- custom_constraint: nova.keypair
instance_flavor:
type: string
default: m1.petit
description: flavor used by the servers
constraints:
- custom_constraint: nova.flavor
public_net:
type: string
default: public
description: Name of public network into which servers get deployed
constraints:
- custom_constraint: neutron.network
private_net:
type: string
default: engnet
description: Name of private network into which servers get deployed
constraints:
- custom_constraint: neutron.network
private_subnet:
type: string
default: engsubnet
description: Name of private subnet into which servers get deployed
constraints:
- custom_constraint: neutron.subnet

usergroup:
type: string
default: stackgroup
description: add unix group
resources:
HeatStack:
type: OS::Nova::Server
properties:
name: { get_param: instance_name }
image: { get_param: image_name }
flavor: { get_param: instance_flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: web_net_port }

web_net_port:
type: OS::Neutron::Port
properties:
network: { get_param: private_net }
fixed_ips:
- subnet: { get_param: private_subnet }
security_groups: [{ get_resource: web_security_group }]

web_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network: { get_param: public_net }
port_id: { get_resource: web_net_port }

web_security_group:
type: OS::Neutron::SecurityGroup
properties:
description: Add security group rules for the multi-tier architecture
name: HeatStack
rules:
- remote_ip_prefix: 0.0.0.0/0
protocol: tcp
port_range_min: 22
port_range_max: 22
- remote_ip_prefix: 0.0.0.0/0
protocol: tcp
port_range_min: 80
port_range_max: 80
- remote_ip_prefix: 0.0.0.0/0
protocol: icmp

outputs:
web_private_ip:
description: Private IP address of the web server
value: { get_attr: [ HeatStack, first_address ] }

web_public_ip:
description: External IP address of the web server
value: { get_attr: [ web_floating_ip, floating_ip_address ] }

website_url:
description: >
This URL is the "external" URL that can be used to access the
web server.
value:
str_replace:
template: http://host/index.php
params:
host: { get_attr: [web_floating_ip, floating_ip_address] }