Skip to content

Instantly share code, notes, and snippets.

@jyidiego
Last active August 29, 2015 14:09
Show Gist options
  • Save jyidiego/82b73f67f432866bd6ee to your computer and use it in GitHub Desktop.
Save jyidiego/82b73f67f432866bd6ee to your computer and use it in GitHub Desktop.
django single server rackspace
parameter_groups:
-
parameters:
- flavor
- image
- server_count
label: 'Server Settings'
-
parameters:
- db_flavor
- db_user
- db_size
- datastore_version
label: 'Database Settings'
-
parameters:
- project_name
- app_name
- django_admin_user
- django_admin_email
- virtualenv
- venv_username
label: 'Django Settings'
-
parameters:
- load_balancer_hostname
- server_hostname
- kitchen
- chef_version
label: rax-dev-params
heat_template_version: '2013-05-23'
description: "Heat template to deploy a load balancer, multiple servers running Django, and a Cloud Database\n"
parameters:
server_hostname:
default: django-%index%
label: 'Server Hostname'
type: string
description: 'Host name to give the servers provisioned'
constraints:
-
length:
max: 64
min: 1
-
allowed_pattern: '^[a-zA-Z][a-zA-Z0-9%-]*$'
description: "Must begin with a letter and contain only alphanumeric characters.\n"
project_name:
default: mysite
label: 'Project Name'
type: string
description: 'The name to use to create your Django project.'
constraints:
-
allowed_pattern: '^[A-Za-z0-9_]{1,31}$'
description: "Must be alphanumeric and fewer than 32 chanracters.\n"
app_name:
default: myapp
label: 'Application Name'
type: string
description: 'The name of your Django application.'
constraints:
-
allowed_pattern: '^[A-Za-z0-9_]{1,31}$'
description: "Must be alphanumeric and fewer than 32 chanracters.\n"
db_flavor:
default: '2GB Instance'
label: 'Cloud Database Size'
type: string
description: "Required: Rackspace Cloud Database Flavor. Size is based on amount of RAM\nfor the provisioned instance.\n"
constraints:
-
description: "Must be a valid Rackspace Cloud Database flavor for the region you have\nselected to deploy into.\n"
allowed_values:
- '512MB Instance'
- '1GB Instance'
- '2GB Instance'
- '4GB Instance'
- '8GB Instance'
- '16GB Instance'
image:
default: 'Ubuntu 12.04 LTS (Precise Pangolin) (PVHVM)'
label: 'Operating System'
type: string
description: "Required: Server image used for all servers that are created as a part of\nthis deployment.\n"
constraints:
-
description: 'Must be a supported operating system.'
allowed_values:
- 'Ubuntu 12.04 LTS (Precise Pangolin) (PVHVM)'
load_balancer_hostname:
default: Django-Load-Balancer
label: Hostname
type: string
description: 'Hostname for the Load Balancer'
constraints:
-
length:
max: 64
min: 1
-
allowed_pattern: '^[a-zA-Z][a-zA-Z0-9-]*$'
description: "Must begin with a letter and contain only alphanumeric characters.\n"
venv_username:
default: pydev
label: 'System User'
type: string
description: "Username with which to login to the Linux servers. This user\nwill be the owner of the Python Virtual Environment under which Django\nis installed.\n"
constraints:
-
allowed_pattern: '^(?!^root$)([a-z_][a-z0-9_]{0,30})$'
description: 'alphanumeric, lowercase, and not root.'
db_size:
default: 10
label: 'Database Size'
type: number
description: "Database instance size, in GB. min 10, max 150\n"
constraints:
-
range:
max: 150
min: 10
flavor:
default: '1 GB General Purpose v1'
label: 'Server Size'
type: string
description: "Required: Rackspace Cloud Server flavor to use. The size is based on the\namount of RAM for the provisioned server.\n"
constraints:
-
description: "Must be a valid Rackspace Cloud Server flavor for the region you have\nselected to deploy into.\n"
allowed_values:
- '1 GB General Purpose v1'
- '2 GB General Purpose v1'
- '4 GB General Purpose v1'
- '8 GB General Purpose v1'
- '15 GB I/O v1'
- '30 GB I/O v1'
- '60 GB I/O v1'
- '90 GB Performance'
- '1GB Standard Instance'
- '2GB Standard Instance'
- '4GB Standard Instance'
- '8GB Standard Instance'
- '15GB Standard Instance'
- '30GB Standard Instance'
server_count:
default: 2
label: 'Server Count'
type: number
description: 'Number of servers to deploy'
constraints:
-
range:
max: 25
min: 1
description: 'Must be between 0 and 24 servers.'
kitchen:
default: 'https://github.com/rackspace-orchestration-templates/django-clouddb'
type: string
description: "URL for the kitchen to use, fetched using git\n"
label: Kitchen
virtualenv:
default: venv
type: string
description: "Python Virtual Environment in which Django will be installed.\nIt will be created in the /srv directory.\n"
label: virtualenv
datastore_version:
default: '5.6'
label: 'MySQL Version'
type: string
description: "Required: Version of MySQL to run on the Cloud Databases instance.\n"
constraints:
-
allowed_values:
- '5.6'
- '5.1'
child_template:
default: 'https://raw.github.com/rackspace-orchestration-templates/django-clouddb/master/django-single.yaml'
type: string
description: 'Location of child template'
label: 'Child Template'
db_user:
default: db_user
label: 'Database Username'
type: string
description: "Required: Username for the database.\n"
constraints:
-
allowed_pattern: '^(.){1,16}$'
description: "Must be shorter than 16 characters, this is due to MySQL's maximum\nusername length.\n"
django_admin_email:
default: admin@example.com
label: 'Admin Email'
type: string
description: 'Email address'
constraints:
-
allowed_pattern: '^(?=.*).{0,512}$'
description: "Must be less than 512 chanracters.\n"
django_admin_user:
default: djangouser
label: 'Admin User'
type: string
description: 'Administrative username for logging into Django.'
constraints:
-
allowed_pattern: '^(?=.*).{0,256}$'
description: "Must be less than 256 chanracters.\n"
chef_version:
default: 11.14.6
type: string
description: 'Version of chef client to use'
label: 'Chef Version'
outputs:
private_key:
description: 'SSH Private Key'
value:
get_attr:
- ssh_key
- private_key
load_balancer_ip:
description: 'Load Balancer IP'
value:
get_attr:
- load_balancer
- PublicIp
server_ips:
description: 'Server IPs'
value:
get_attr:
- django_setup
- accessIPv4
db_user:
description: 'Database Username'
value:
get_param: db_user
django_url:
description: 'Django URL'
value:
str_replace:
params:
'%ip%':
get_attr:
- load_balancer
- PublicIp
template: 'http://%ip%'
db_pass:
description: 'Database User Password'
value:
get_attr:
- db_pass
- value
db_name:
description: 'Database Name'
value: app_data
db_host:
description: 'Database Host'
value:
get_attr:
- service_db
- hostname
django_admin_pass:
description: 'Django Admin Password'
value:
get_attr:
- django_admin_pass
- value
resources:
load_balancer:
depends_on:
- django_setup
type: 'Rackspace::Cloud::LoadBalancer'
properties:
protocol: HTTP
name:
get_param: load_balancer_hostname
algorithm: ROUND_ROBIN
virtualIps:
-
ipVersion: IPV4
type: PUBLIC
contentCaching: ENABLED
healthMonitor:
delay: 10
attemptsBeforeDeactivation: 1
type: CONNECT
timeout: 5
nodes:
-
addresses:
get_attr:
- django_setup
- privateIPv4
condition: ENABLED
port: 80
port: 80
metadata:
rax-heat:
get_param: 'OS::stack_id'
db_pass:
type: 'OS::Heat::RandomString'
properties:
length: 16
sequence: hexdigits
service_db:
type: 'OS::Trove::Instance'
properties:
size:
get_param: db_size
users:
-
password:
get_attr:
- db_pass
- value
name:
get_param: db_user
databases:
- app_data
databases:
-
name: app_data
datastore_type: mysql
flavor:
get_param: db_flavor
datastore_version:
get_param: datastore_version
name: app_db
ssh_key:
type: 'OS::Nova::KeyPair'
properties:
name:
get_param: 'OS::stack_id'
save_private_key: true
django_admin_pass:
type: 'OS::Heat::RandomString'
properties:
length: 16
sequence: hexdigits
django_setup:
depends_on: service_db
type: 'OS::Heat::ResourceGroup'
properties:
count:
get_param: server_count
resource_def:
type:
get_param: child_template
properties:
server_hostname:
get_param: server_hostname
private_key:
get_attr:
- ssh_key
- private_key
project_name:
get_param: project_name
app_name:
get_param: app_name
image:
get_param: image
db_pass:
get_attr:
- db_pass
- value
venv_username:
get_param: venv_username
parent_stack_id:
get_param: 'OS::stack_id'
flavor:
get_param: flavor
kitchen:
get_param: kitchen
virtualenv:
get_param: virtualenv
ssh_keypair_name:
get_resource: ssh_key
database_host:
get_attr:
- service_db
- hostname
db_user:
get_param: db_user
django_admin_email:
get_param: django_admin_email
django_admin_user:
get_param: django_admin_user
chef_version:
get_param: chef_version
django_admin_pass:
get_attr:
- django_admin_pass
- value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment