Builds a production-style Hydra head on an Ubuntu 14.04 Amazon EC2 instance or a vagrant box.
Ansible 1.9 or above.
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.
To create, set up an ec2 instance:
- Copy group_vars/sample_all to group_vars/all.
- Add your organization's AWS credentials there.
- Add/change any other variables you wish to override.
- Consider protecting group_vars/all with ansible-vault.
- run
ansible-playbook -i ec2.py --private-key /path/to/your/keypair.pem create_ec2.yml --extra-vars "hosts=tomcat"
5a.runansible-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"
- Optional: if you encrypted your variables with ansible-vault, add
- 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.
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'
To set up a production-like Vagrant box (for staging, troubleshooting) for your project:
- 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
- Clone this repository alongside your project
- 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.
- cd into your project and run
vagrant up
- TODO: deploy your capistrano project to your vagrant box. Haven't tried this yet.
- Create a Vagrant file in your project
- (see sample_Vagrantfile for ideas)
- Be sure to point to the vagrant_dev.yml file
- Clone this repository alongside your project
- 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.
- In your application code, edit
- development section of config/blacklight.yml to url: http://localhost:8080/hydra/collection1
- development section of config/fedora.yml to url: http://127.0.0.1:8080/fedora/rest
- create a file config/solr.yml with a development section containing url: http://localhost:8080/hydra
- (see roles/hydra-stack/config/ for more context)
- run
vagrant up
- 'vagrant ssh'; cd /vagrant; 'bundle install'
- sudo service resque-pool start (resque-pool can't start until bundler has run)
- sudo service apache2 restart
Contributions are welcome in the form of issues (including bug reports, use cases) and pull requests.
This Ansible project was created by Data Curation Experts for the Chemical Heritage Foundation.