Skip to content

Instantly share code, notes, and snippets.

@hhoover
Created April 7, 2014 18: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 hhoover/10027592 to your computer and use it in GitHub Desktop.
Save hhoover/10027592 to your computer and use it in GitHub Desktop.
django-single.yaml
heat_template_version: 2013-05-23
description: |
Heat template to deploy a single Django server
parameters:
database_host:
description: Cloud Database hostname.
type: string
server_hostname:
description: Server Name
type: string
default: django
constraints:
- length:
min: 1
max: 64
- allowed_pattern: "^[a-zA-Z][a-zA-Z0-9-]*$"
description: |
Must begin with a letter and contain only alphanumeric characters.
server_count:
description: Number of servers to deploy
type: number
default: 1
constraints:
- range:
min: 0
max: 24
description: Must be between 0 and 24 servers.
image:
description: Server Image
type: string
default: Ubuntu 12.04 LTS (Precise Pangolin)
constraints:
- allowed_values:
- Ubuntu 12.04 LTS (Precise Pangolin)
description: Must be a supported operating system.
flavor:
description: Rackspace Cloud Server flavor
type: string
default: 4 GB Performance
constraints:
- allowed_values:
- 1 GB Performance
- 2 GB Performance
- 4 GB Performance
- 8 GB Performance
- 15 GB Performance
- 30 GB Performance
- 60 GB Performance
- 90 GB Performance
- 512MB Standard Instance
- 1GB Standard Instance
- 2GB Standard Instance
- 4GB Standard Instance
- 8GB Standard Instance
- 15GB Standard Instance
- 30GB Standard Instance
description: |
Must be a valid Rackspace Cloud Server flavor for the region you have
selected to deploy into.
db_user:
description: "Username for the database."
type: string
default: db_user
constraints:
- allowed_pattern: "^(.){1,16}$"
description: |
Must be shorter than 16 characters, this is due to MySQL's maximum
username length.
db_pass:
type: string
hidden: true
description: Database access password
default: secret123
ssh_keypair_name:
description: Nova keypair name for ssh access to the server
type: string
default: django-app
virtualenv:
label: virtualenv
type: string
default: venv
description: |
Python Virtual Environment in which Django will be installed.
It will be created in the /srv directory.
project_name:
type: string
description: The name to use to create your Django project.
default: mysite
constraints:
- allowed_pattern: "^[A-Za-z0-9_]{1,31}$"
description: |
Must be alphanumeric and fewer than 32 chanracters.
app_name:
type: string
description: The name of your app.
default: myapp
constraints:
- allowed_pattern: "^[A-Za-z0-9_]{1,31}$"
description: |
Must be alphanumeric and fewer than 32 chanracters.
django_admin_user:
type: string
description: Username for login to Django
default: djangouser
constraints:
- allowed_pattern: "^(?=.*).{0,256}$"
description: |
Must be less than 256 chanracters.
django_admin_email:
type: string
description: Email address
default: admin@example.com
constraints:
- allowed_pattern: "^(?=.*).{0,512}$"
description: |
Must be less than 512 chanracters.
django_admin_pass:
type: string
hidden: true
description: Django admin password
default: secret123
venv_username:
label: System User
type: string
default: pydev
description: |
Username with which to login to the Linux servers. This user
will be the owner of the Python Virtual Environment under which Django
is installed.
constraints:
- allowed_pattern: "^(?!^root$)([a-z_][a-z0-9_]{0,30})$"
description: alphanumeric, lowercase, and not root.
private_key:
description: Private SSH key
type: string
default: false
resources:
django_server:
type: "Rackspace::Cloud::Server"
properties:
name: { get_param: server_hostname }
flavor: { get_param: flavor }
image: { get_param: image }
key_name: { get_param: ssh_keypair_name }
bootstrap_server:
type: "OS::Heat::ChefSolo"
properties:
username: root
private_key: { get_param: private_key }
host: { get_attr: [django_server, accessIPv4] }
Berksfile: |
site :opscode
cookbook 'apt'
cookbook 'build-essential'
node:
run_list: ["recipe[apt]",
"recipe[build-essential]"]
django_setup:
type: "OS::Heat::ChefSolo"
depends_on: bootstrap_server
properties:
username: root
private_key: { get_param: private_key }
host: { get_attr: [django_server, accessIPv4] }
Berksfile: |
site :opscode
cookbook 'build-essential'
cookbook 'apt'
cookbook 'chef-client'
cookbook 'apache2'
cookbook 'python'
cookbook 'python-django',
:git => 'https://github.com/hhoover/python-django.git'
cookbook 'sudo'
node:
django:
username: { get_param: venv_username }
virtualenv: { get_param: virtualenv }
project_name: { get_param: project_name }
app_name: { get_param: app_name }
database_name: app_data
database_user: { get_param: db_user }
database_password: { get_param: db_pass }
database_host: { get_param: database_host }
django_admin_user: { get_param: django_admin_user }
django_admin_email: { get_param: django_admin_email }
django_admin_pass: { get_param: django_admin_pass }
run_list: ["recipe[python-django]"]
outputs:
server_ip:
value: { get_attr: [django_server, privateIPv4] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment