GithubHelp home page GithubHelp logo

rackspace-orchestration-templates / rails-app-single Goto Github PK

View Code? Open in Web Editor NEW
1.0 5.0 5.0 1.22 MB

Rackspace Heat template to deploy a standalone Rails application server with a local database

License: Apache License 2.0

Ruby 77.78% Perl 6.10% HTML 13.86% Shell 2.16% Python 0.11%

rails-app-single's Introduction

Circle CI Description

This template deploys a Ruby on Rails application from a git repo under either unicorn & nginx, or mod_passenger & Apache 2 on multiple Linux servers with OpenStack Heat on the Rackspace Cloud, with either a Postgres or MySQL back end. This template uses the chef-solo provider to configure the servers.

Requirements

  • A Heat provider that supports the Rackspace OS::Heat::ChefSolo plugin.
  • An OpenStack username, password, and tenant id.
  • python-heatclient >= v0.2.8:
pip install python-heatclient

We recommend installing the client within a Python virtual environment.

Example Usage

Here is an example of how to deploy this template using the python-heatclient:

heat --os-username <OS-USERNAME> --os-password <OS-PASSWORD> --os-tenant-id \
  <TENANT-ID> --os-auth-url https://identity.api.rackspacecloud.com/v2.0/ \
  stack-create myrailsapp -f rails-app-multi.yaml \
  -P rails_rake_tasks=kandan:bootstrap -P rails_app_server_count=5 \
  -P rails_db_type=mysql -P rails_db_adapter=mysql2 \
  -P ruby_version=1.9.3-p547 -P app_git_url=https://github.com/myorg/myapp
  • For UK customers, use https://lon.identity.api.rackspacecloud.com/v2.0/ as the --os-auth-url.

Optionally, set environment variables to avoid needing to provide these values every time a call is made:

export OS_USERNAME=<USERNAME>
export OS_PASSWORD=<PASSWORD>
export OS_TENANT_ID=<TENANT-ID>
export OS_AUTH_URL=<AUTH-URL>

Parameters

Parameters can be replaced with your own values when standing up a stack. Use the -P flag to specify a custom parameter.

  • image: Operating system to use (Default: Ubuntu 12.04 LTS (Precise Pangolin))
  • flavor: Server size to use for the application server (Default: 4 GB Performance)
  • additional_packages: Space delimited list of additional system packages to install. List any packages here required for your Gems to build. (Default: none)
  • domain: Domain to be used with the rails app site, this will be used when setting up web services. (Default: rails.example.com)
  • ruby_version: Version of Ruby to install (Default: 2.1.2)
  • rails_environment: string to use as the rails environment name (Default: production)
  • rails_app_server: Application server to hose your Rails Application (Default: unicorn)
  • rails_db_type: Type of database to install, either postgresql or mysql (Default: mysql)
  • rails_db_adapter: Database adapter override. If supplied, this string will be used in the database.yml file to specify the adapter. By default rails_db_type will be used. You will need to use this for alternate adapters such as mysql2.
  • rails_rake_tasks: a space-separated list of additional rake tasks to run after db:migrate and assets:precompile are run. (Default: none)
  • app_git_url: Specifies a git URL from which to deploy the app (Default: none)
  • app_git_revision: git branch, tag, or hash of the application revision to deploy. (Default: master)
  • app_deploy_key: Private key for deployment from a private git repo. (Default: none)
  • database_name: Name of the MySQL/Postgresql database to create for the application. (Default: railsapp_db)
  • database_username: User name for the MySQL/Postgresql database user to create for this application. (Default: railsapp_user)
  • kitchen: URL for the kitchen to clone with git. The Chef Solo run will copy all files in this repo into the kitchen for the chef run. (Default: https://github.com/rackspace-orchestration-templates/rails-app-single)
  • chef_version: Chef client version to install for the chef run. (Default: 11.12.8)

Outputs

Once a stack comes online, use heat output-list to see all available outputs. Use heat output-show <OUTPUT NAME> to get the value fo a specific output.

  • private_key: SSH private that can be used to login as root to the servers.
  • server_IP: IP of the server created with this deployment.
  • rails_app_url: URL to access your Rails application via the load balancer

For multi-line values, the response will come in an escaped form. To get rid of the escapes, use echo -e '<STRING>' > file.txt. For vim users, a substitution can be done within a file using %s/\\n/\r/g.

Stack Details

The application is deployed Capistrano-style in the home directory of the rails user in a directory based on the name of the git repo.

Gems dependencies are installed by running a bundle install --deployment in the application directory. This requires a Gemfile.lock in the application repo.

Two rake tasks are run at deployment time: rake db:migrate followed by rake assets:precompile. Additional rake tasks will be run if provided.

If you are using unicorn it must be declared in the application's Gemfile.

A unicorn.rb file is generated and placed in the application's config directory along with a database.yml file configured to reference the deployment's database server.

Contributing

There are substantial changes still happening within the OpenStack Heat project. Template contribution guidelines will be drafted in the near future.

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

rails-app-single's People

Contributors

brint avatar jasonboyles avatar jasondunsmore avatar linuturk avatar pratikmallya avatar rs-randallburt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rails-app-single's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.