The perl module for writing and running all deployment tasks.
First create a project specific local lib environment and install all required modules
123
perlbrew lib create deploy-tasks
perlbrew use lib deploy-perl@deploy-tasks
cpanm -n Rex
Before we start
The remote box should be accessible by ssh.
It also have to be configured for public key based SSH authentication with any
passphrase. It’s recommend not to use the default one,
1
ssh-keygen -t rsa -f [filename]
Then add the content of ~/.ssh/[filename]_rsa.pub file from
local machine to the ~/.ssh/authorized_keys of
remote machine. Refer to the ssh-key rex task below for this transfer.
Running rex tasks
All the rex task are going to run remotely, so it is not at all needed to be
installed on remote machine.
Create a default Rexfile and add the correct user name and ssh key credentials.
uselib'lib';user'user_name';# global sudosudo_password'48343jfen';sudo-on;private_key'path_to_private_key';public_key'path_to_public_key';key_auth;requireTasks;
To run a non-default Rexfile
1
rex -H <host> -f [other_file] task_name
Last but not the least
The shared folder is assumed to be hosted on a separated partition. It has to be created
with an ext4 filesystem before any of the task is being run.
However in case of shared device which is already mounted the above step is not needed.
Refer to the Setup shared folder section below for detail.
Various configuration files needed for sys admin tasks are either present in conf.d
folder or mentioned in the detail guide. Make sure to consult them if something is
unclear.
Sys admin tasks
The tasks are assumed to be run on a remote CentOS box and so yum/rpm is selected for
package installation. At this point no heuristics is performed to identify the type of
remote box.
Quick steps
Create a yaml file in $HOME/.rex/config.yml and run the given Rex tasks
# sets up various command aliases and two groups sys and developer# with varying level of accesssudo:file:conf.d/sudoers.multigenome# create the groups and then add the user to that group# could add extra groups separated by colongroup:name:'developer:sys:deploy'user:user:newuserpass:newpassgroups:'developer:deploy'# the device should have an ext4 partition and shared folder will be the only folder# occupying the partitionshared:group:deployfolder:'/shared'device:'/dev/sdb1'# uncomment the following section for shared folder if it has to coexist with other folder in# the device. Make sure you comment the previous section. #'shared-remount':# group: deploy# folder: '/home/shared'# base: '/home'# Download rpms from here# http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.htmloracle:rpm:'/home/user/downloads/rpms'file:'conf.d/tnsnames.ora'host:localhostsid:orclservice:servedmojo:mode:staging# look in the step by step section for sample filesapache:envvars:file:'env.sh'vhost:file:'conf.d/apache_site.conf'name:genomeperl:file:'conf.d/perl.conf'# this should match the shared folder perlbrew:root:'/shared'perl:'5.10.1'
Rex tasks
123456
rex -H <host> -s setup:dicty:box
rex -H <host> setup:dicty:perl
# check for status of perl installation before running the toolchain taskrex -H <host> perl:install-status
rex -H <host> setup:dicty:perl-toolchain
Alternate step by step
Skip this entire section if you have already gone through Quick steps
Add extra repositories
1
rex -H <host> -s -S <sudo_pass> add:repos
Add extra sudoers configuration file
1
rex -H <host> -s -S <sudo_pass> add:sudoers --file=conf.d/sudoers.multigenome
Add user to developers and deploy groups
12
rex -H <host> -s -S <sudo_pass> add:groups --name=developer:deploy
rex -H <host> -s -S <sudo_pass> add:user --user=<user> --pass=<pass> --groups=developer:deploy
Install packages
1
rex -H <host> -s -S <sudo_pass> install:dicty-pack
Setup shared folder
123
Remember the device is expected to have a ext4 partition
rex -H <host> -s -S <sudo_pass> setup:shared-folder --group=[deploy]\ --folder=[/dictybase] --device=[]
The above task is suitable when the entire device is dedicated for the shared folder.
However, if the shared folder has to coexist in a device(shared folder) with other
folders, the run the following task …
12
rex -H <host> -s -S <sudo_pass> setup:shared-folder-remount --group=[deploy]\ --folder=[/dictybase] --base-folder[$HOME]
It will remount the base folder with acl and sets the proper share permission for the
folder. However, it is not persistent over reboot, so add the acl entry to fstab
manually to make it stick.
Set daemontools
1
rex -H <host> -s -S <sudo_pass> setup:daemontools
Mojolicious web application setup
1
rex -H <host> -s -S <sudo_pass> setup:global-mojo --mode=[staging|production]
Apache setup
1
rex -H <host> -s -S <sudo_pass> setup:apache:envvars --file=[file]
## -- Including all conf file for each web application## -- Assuming here that mod_perl is included in apache2<Perl>my $folder = $ENV{WEBAPPS_DIR};
if (-e $folder) {
opendir my $web, $folder or die "cannot open dir $!";
my @dirs = map {"$folder/$_"} grep {/^[A-Z, a-z,\-]+$/} readdir $web;
closedir $web;
for my $name(@dirs) {
my $config = "$name/deploy/apache.conf";
if (-e $config) {
push @Include,$config;
}}}</Perl>
1
rex -H <host> -s -S <sudo_pass> setup:apache:startup
Oracle client setup
It installs the instant client rpms and sets up oracle environment
globally. Oracle instantclient could be downloaded from
here. For here we
need three rpms
rex -H <host> -S <sudo_pass> setup:oracle-client --rpm=rpms
rex -H <host> -S <sudo_pass> setup:oracle:tnsnames --file=[file]\ --host=[host] --sid=[sid] --service=[service_name]
Setup perl environment
perl environment for deployment will be setup using perlbrew in the shared
folder(/dictybase). The first task requires sudo access if system argument is given.
12345
rex -H <host> -s perlbrew:install --install-root=/dictybase/perl5 --system=1
rex -H <host> perlbrew:install-cpanm
rex -H <host> perl:install-notest
rex -H <host> perlbrew:switch --version=perl-5.10.1
rex -H <host> perl:install-toolchain