Skip to content

Instantly share code, notes, and snippets.

@dvirperetz
Created June 13, 2017 15:32
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 dvirperetz/69c201f622f2edffafcfe34b5a2bb405 to your computer and use it in GitHub Desktop.
Save dvirperetz/69c201f622f2edffafcfe34b5a2bb405 to your computer and use it in GitHub Desktop.
selection of a web app install - OpenStack
#
# This is a hello world HOT template with app install selection
#
heat_template_version: 2015-04-30
description: >
Hello world HOT template that just defines a single server.
Contains just base features to verify base HOT support.
parameters:
key_name:
type: string
description: Name of an existing key pair to use for the server
default: "topcat-01"
constraints:
- custom_constraint: nova.keypair
flavor:
type: string
description: Flavor for the server to be created
default: m1.normal
constraints:
- custom_constraint: nova.flavor
image:
type: string
description: Image ID or image name to use for the server
default: Ubuntu-1404lts-32-Cloud
constraints:
- custom_constraint: glance.image
my_network:
type: string
description: Neutron Network
default: public-internet-access
constraints:
- custom_constraint: neutron.network
application-install:
type: string
default: apache
constraints:
- allowed_values: [apache, nginx]
description: Value must be one of 'apache', or 'nginx'
resources:
server:
type: OS::Nova::Server
properties:
key_name: { get_param: key_name }
image: { get_param: image }
flavor: { get_param: flavor }
security_groups:
- default
name: test-single-topcat-instance
networks:
- network: { get_param: my_network }
user_data_format: RAW
user_data:
str_replace:
template: |
#!/bin/bash
myapp="$selectedapp01"
echo "MY APP IS $myapp"
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
case $myapp in
apache)
echo "INSTALLING APACHE"
if [ -f /etc/debian_version ]
then
aptitude -y update
aptitude -y install apache2
fi
if [ -f /etc/redhat-release ]
then
yum -y install httpd
chkconfig httpd on
echo "" >> /var/www/html/index.html
service httpd start
fi
;;
nginx)
echo "INSTALLING NGINX"
if [ -f /etc/debian_version ]
then
aptitude -y update
aptitude -y install nginx-full
fi
if [ -f /etc/redhat-release ]
then
yum -y install nginx
chkconfig nginx on
service nginx start
fi
;;
esac
params:
$selectedapp01: {get_param: application-install}
outputs:
server_networks:
description: The networks of the deployed server
value: { get_attr: [server, networks] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment