An Ansible role for installing and managing Galaxy servers. Despite the name confusion, Galaxy bears no relation to Ansible Galaxy.
This role has the same dependencies as the hg
module, namely,
Mercurial. In addition, Python virtualenv is required (as is
pip, but pip will automatically installed with virtualenv). These can
easily be installed via a pre-task in the same play as this role:
- hosts: galaxyservers
pre_tasks:
- name: Install Mercurial
apt: pkg={{ item }} state=installed
sudo: yes
when: ansible_os_family = 'Debian'
with_items:
- mercurial
- python-virtualenv
- name: Install Mercurial
yum: pkg={{ item }} state=installed
sudo: yes
when: ansible_os_family = 'RedHat'
with_items:
- mercurial
- python-virtualenv
roles:
- galaxy
If your hg
executable is not on $PATH
, you can specify its location with
the hg_executable
variable. Likewise with the virtualenv
executable and
corresponding pip_virtualenv_command
variable.
galaxy_server_dir
: Filesystem path where the Galaxy server code will be installed (cloned).
Several variables control which functions this role will perform (all default
to yes
):
galaxy_manage_clone
: Clone Galaxy from the source repository and maintain it at a specified version (changeset), as well as set up a [virtualenv][virtualenv] from which it can be run.galaxy_manage_static_setup
: Manage "static" Galaxy configuration files - ones which are not modifiable by the Galaxy server itself. At a minimum, this is the primary Galaxy configuration file, universe_wsgi.ini.galaxy_manage_mutable_setup
: Manage "mutable" Galaxy configuration files - ones which are modifiable by Galaxy (e.g. as you install tools from the Galaxy Tool Shed).galaxy_manage_database
: Upgrade the database schema as necessary, when new schema versions become available.galaxy_fetch_eggs
: Fetch Galaxy dependent modules (packaged as Python eggs).
You can control various things about where you get Galaxy from, what version you use, and where its configuration files will be placed:
galaxy_repo
(default:https://bitbucket.org/galaxy/galaxy-dist
): Upstream Mercurial repository from which Galaxy should be cloned.galaxy_changeset_id
(default:stable
): A changeset id, tag, branch, or other valid Mercurial identifier for which changeset Galaxy should be updated to. Specifying a branch will update to the latest changeset on that branch. A debugging message will notify you if the current changeset of your Galaxy server is different from this value. There is no harm in this, but:- if this annoys you, you must use a full (long) changeset hash to prevent that task from reporting changed on every run, and
- using a real changeset hash is the only way to explicitly lock Galaxy at a specific version.
galaxy_venv_dir
(default:<galaxy_server_dir>/.venv
): The role will create a [virtualenv][virtualenv] from which Galaxy will run, this controls where the virtualenv will be placed.galaxy_config_dir
(default:<galaxy_server_dir>
): Directory that will be used for "static" configuration files.galaxy_mutable_config_dir
(default:<galaxy_server_dir>
): Directory that will be used for "mutable" configuration files, must be writable by the user running Galaxy.galaxy_mutable_data_dir
(default:<galaxy_server_dir>/database
): Directory that will be used for "mutable" data and caches, must be writable by the user running Galaxy.galaxy_config_file
(default:<galaxy_config_dir>/universe_wsgi.ini
): Galaxy's primary configuration file.galaxy_shed_tool_conf_file
(default:<galaxy_mutable_config_dir>/shed_tool_conf.xml
): Configuration file for tools installed from the Galaxy Tool Shed.galaxy_config
: The contents of the Galaxy configuration file (universe_wsgi.ini by default) are controlled by this variable. It is a hash of hashes (or dictionaries) that will be translated in to the configuration file. See the Example Playbooks below for usage.galaxy_config_files
: List of hashes (withsrc
anddest
keys) of files to copy from the control machine.galaxy_config_template
: List of hashes (withsrc
anddest
keys) of templates to fill from the control machine.galaxy_admin_email_to
: If set, email this address when Galaxy has been updated. Assumes mail is properly configured on the managed host.galaxy_admin_email_from
: Address to send the aforementioned email from.
None
NOTE: The ability to skip Galaxy's built-in setup routines and fully separate the config directory from the server directory relies on features that will not be available in the stable version of Galaxy until the October, 2014 release.
Install Galaxy on your local system with all the default options:
- hosts: localhost
vars:
galaxy_server_dir: /home/nate/galaxy-dist
connection: local
roles:
- galaxy
Once installed, you can start with:
% cd /home/nate/galaxy-dist
% python ./scripts/paster.py serve universe_wsgi.ini
Install Galaxy with the clone and configs owned by a different user than the
user running Galaxy, and backed by PostgreSQL, on the hosts in the
galaxyservers
group in your inventory:
- hosts: galaxyservers
vars:
galaxy_server_dir: /opt/galaxy/server
galaxy_config_dir: /opt/galaxy/config
galaxy_mutable_config_dir: /var/opt/galaxy/config
galaxy_mutable_data_dir: /var/opt/galaxy/data
galaxy_repo: https://bitbucket.org/galaxy/galaxy-central/
galaxy_changeset_id: tip
postgresql_objects_users:
- name: galaxy
password: null
postgresql_objects_databases:
- name: galaxy
owner: galaxy
galaxy_config:
"server:main":
host: 0.0.0.0
"app:main":
database_connection: "postgresql:///galaxy?host=/var/run/postgresql"
pkg_module: '{{ "yum" if ansible_os_family == "RedHat" else "apt" }}'
pre_tasks:
- name: Create Galaxy code owner user
user: name=gxcode comment="Galaxy Code" system=yes home=/opt/galaxy createhome=yes
sudo: yes
- name: Create Galaxy runtime user
user: name=galaxy comment="Galaxy Server" system=yes home=/var/opt/galaxy createhome=yes
sudo: yes
- name: Install Mercurial
action: '{{ pkg_module }} pkg=mercurial state=installed'
sudo: yes
- name: Install virtualenv
action: '{{ pkg_module }} pkg=python-virtualenv state=installed'
sudo: yes
- name: Install psycopg2
action: '{{ pkg_module }} pkg=python-psycopg2 state=installed'
sudo: yes
# Precreating the mutable config directory may be necessary (it's not in
# our example since we set the user's home directory to
# galaxy_mutable_config_dir's parent).
#- name: Create mutable configuration file directory
# file: state=directory path={{ galaxy_mutable_config_dir }} owner=galaxy
# sudo: yes
roles:
# Install with:
# % ansible-galaxy install zzet.postgresql
- zzet.postgresql
# Install with:
# % ansible-galaxy install natefoo.postgresql_objects
- role: natefoo.postgresql_objects
sudo: yes
sudo_user: postgres
- role: galaxy
sudo: yes
sudo_user: gxcode
galaxy_manage_mutable_setup: no
galaxy_manage_database: no
- role: galaxy
sudo: yes
sudo_user: galaxy
galaxy_manage_clone: no
galaxy_manage_static_setup: no