Skip to content

Ansible playbook & roles to build a production-style Hydra Head.

License

Notifications You must be signed in to change notification settings

atlaIT/ansible-hydra

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Builds a production-style Hydra head on an Ubuntu 14.04 Amazon EC2 instance or a vagrant box.

Prerequisites

Ansible 1.9 or above.

AWS / EC2 setup

Step-by-step instructions were presented in our 2015 Hydra Connect talk: Deploying Hydra with Ansible and AWS -- The presentation is image-heavy and the accompanying notes provide more detail.

Execution

To create, set up an ec2 instance:

  1. Copy group_vars/sample_all to group_vars/all.
  2. Add your organization's AWS credentials there.
  3. Add/change any other variables you wish to override.
  4. Consider protecting group_vars/all with ansible-vault.
  5. run ansible-playbook -i ec2.py --private-key /path/to/your/keypair.pem create_ec2.yml --extra-vars "hosts=tomcat" 5a.run ansible-playbook -i ec2.py --private-key /path/to/your/keypair.pem create_ec2.yml --extra-vars "hosts="web"
    • Optional: if you encrypted your variables with ansible-vault, add --ask-vault-pass
    • Optional: The scripts will by default launch an instance tagged 'staging'. If you want a different tag, override the 'aws_tag' variable either in a file (i.e. group_vars/all) or directly from the command line by adding: --extra-vars "aws_tag=production"
  6. Note that this playbook is NOT idempotent -- it creates a new instance on AWS each time it is run.

There's another playbook called configure.yml. It's included by create_ec2 but can also be run separately. This playbook IS idempotent, so it can be used to change configuration at will. Also, AWS-related tasks have been removed (let us know if you run into anything!) so it should be more generalizable.

Deployment

This project expects your code to be deployed with Capistrano. In your Hydra head (the codebase you're deploying), configure Capistrano for your server(s). In config/deploy.rb and/or in config/deploy/<yourenv>.rb you must:
* share the log directory by including log in your Capistrano linked_dirs list and
* set the Capistrano :deploy_to directory to match the capistrano_setup role's project_base variable. If you use the default value for project_base in the capistrano_setup role, you should use

set :deploy_to, '/opt/sufia-project'

Vagrant

Vagrant

A production-like vagrant box

To set up a production-like Vagrant box (for staging, troubleshooting) for your project:

  1. Create a Vagrant file in your project
  • (see sample_Vagrantfile for ideas)
  • Be sure to point to the vagrant_staging.yml file, which skips aws-related roles
  1. Clone this repository alongside your project
  2. Copy group_vars/sample_all to group_vars/all.
  • Add/change any other variables you wish to override.
  • Consider protecting group_vars/all with ansible-vault.
  1. cd into your project and run vagrant up
  2. TODO: deploy your capistrano project to your vagrant box. Haven't tried this yet.

A development vagrant box

  1. Create a Vagrant file in your project
  • (see sample_Vagrantfile for ideas)
  • Be sure to point to the vagrant_dev.yml file
  1. Clone this repository alongside your project
  2. Copy group_vars/sample_all to group_vars/all.
  • Add/change any other variables you wish to override.
  • Consider protecting group_vars/all with ansible-vault.
  1. In your application code, edit
  1. run vagrant up
  2. 'vagrant ssh'; cd /vagrant; 'bundle install'
  3. sudo service resque-pool start (resque-pool can't start until bundler has run)
  4. sudo service apache2 restart

Contributing

Contributions are welcome in the form of issues (including bug reports, use cases) and pull requests.

Origins

This Ansible project was created by Data Curation Experts for the Chemical Heritage Foundation.

About

Ansible playbook & roles to build a production-style Hydra Head.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 85.7%
  • Ruby 7.4%
  • Shell 6.5%
  • Makefile 0.4%