fetsite installation
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
# Install 1 or more versions of ruby
|
||||
# The last ruby listed will be set as the default ruby
|
||||
rvm1_rubies:
|
||||
- 'ruby-2.1.0'
|
||||
- 'ruby-2.3.1'
|
||||
- '2.1.0'
|
||||
- '2.3.1'
|
||||
|
||||
# Install bundler
|
||||
rvm1_bundler_install: True
|
||||
@@ -45,7 +45,7 @@ rvm1_gpg_keys: '409B6B1796C275462A1703113804BB82D39DC0E3'
|
||||
rvm1_gpg_key_server: 'hkp://keys.gnupg.net'
|
||||
|
||||
# autolib mode, see https://rvm.io/rvm/autolibs
|
||||
rvm1_autolib_mode: 3
|
||||
rvm1_autolib_mode: read-only
|
||||
|
||||
# Name of UID 0 user
|
||||
root_user: 'root'
|
||||
@@ -61,3 +61,25 @@ ruby_req_packages:
|
||||
- gzip
|
||||
- bzip2
|
||||
- default-libmysqlclient-dev
|
||||
- gawk
|
||||
- g++
|
||||
- gcc
|
||||
- libc6-dev
|
||||
- libreadline6-dev
|
||||
- zlib1g-dev
|
||||
- libyaml-dev
|
||||
- libsqlite3-dev
|
||||
- sqlite3
|
||||
- autoconf
|
||||
- libgmp-dev
|
||||
- libgdbm-dev
|
||||
- libmagickwand-dev
|
||||
- imagemagick
|
||||
- libncurses5-dev
|
||||
- bison
|
||||
- libffi-dev
|
||||
- libssl1.0-dev
|
||||
ruby_sites: []
|
||||
|
||||
|
||||
#- libssl-dev
|
||||
|
||||
@@ -1,15 +1 @@
|
||||
ruby_sites:
|
||||
- name: "Seite 1"
|
||||
become_user: "ruby"
|
||||
git:
|
||||
repo: "/mnt/intern"
|
||||
dest: "/srv/intern/intern"
|
||||
- name: "Fetsite"
|
||||
become_user: "ruby"
|
||||
git:
|
||||
repo: "/mnt/fetsite"
|
||||
dest: "/srv/fetsite/fetsite"
|
||||
ruby_init: true
|
||||
|
||||
|
||||
# repo: "https://github.com/kbroman/simple_site"
|
||||
6
tasks/fetsite.yml
Normal file
6
tasks/fetsite.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
- name: Install RVM
|
||||
include: 'rvm.yml'
|
||||
become: yes
|
||||
become_user: "{{ rvm1_user }}"
|
||||
|
||||
- name: Install ruby requirements
|
||||
command: '{{ rvm1_rvm }} requirements'
|
||||
changed_when: False
|
||||
when: rvm1_rubies
|
||||
|
||||
|
||||
- name: Install Ruby and Gems
|
||||
@@ -25,7 +31,47 @@
|
||||
become: yes
|
||||
become_user: "{{ rvm1_user }}"
|
||||
|
||||
- name: "deploying ruby sites"
|
||||
include_tasks: site.yml
|
||||
|
||||
|
||||
- name: "create directory for {{item.name}}"
|
||||
file:
|
||||
path: "{{item.dest}}"
|
||||
state: directory
|
||||
owner: "{{ rvm1_user }}"
|
||||
group: "{{ rvm1_user }}"
|
||||
with_items: "{{ruby_sites}}"
|
||||
|
||||
|
||||
- name: Template for InitScript
|
||||
template:
|
||||
src: ruby_fetsite.j2
|
||||
dest: "{{site.dest}}/../{{site.script}}"
|
||||
owner: "{{ rvm1_user }}"
|
||||
group: "{{ rvm1_user }}"
|
||||
mode: "u=rwx,g=rwx,o=r"
|
||||
when: not(site.script is undefined)
|
||||
with_items: "{{ruby_sites}}"
|
||||
loop_control:
|
||||
loop_var: site
|
||||
|
||||
|
||||
- name: Deploying sites
|
||||
include: site.yml
|
||||
become: yes
|
||||
become_user: "{{ rvm1_user }}"
|
||||
with_items: "{{ruby_sites}}"
|
||||
loop_control:
|
||||
loop_var: site
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
with_items: '{{ rvm1_rubies }}'
|
||||
when: rvm1_rubies
|
||||
|
||||
|
||||
- name: Install rubies
|
||||
command: '{{ rvm1_rvm }} install {{ item.item }} {{ rvm1_ruby_install_flags }}'
|
||||
when: rvm1_rubies and item.rc|default(0) != 0
|
||||
|
||||
@@ -1,66 +1,45 @@
|
||||
# Deploy a ruby site
|
||||
# item:
|
||||
# name: Seite
|
||||
# git:
|
||||
# repo: https://git_repository
|
||||
# dest: destination on server
|
||||
---
|
||||
|
||||
- debug:
|
||||
msg: "Seite: {{item.name}}"
|
||||
msg: "deploy ruby site: {{site.name}}"
|
||||
|
||||
- command: whoami
|
||||
register: whoami
|
||||
- command: echo "$PATH"
|
||||
register: out
|
||||
changed_when: false
|
||||
- debug: msg="{{ out.stdout }}"
|
||||
|
||||
|
||||
- debug: msg="{{ whoami.stdout }}"
|
||||
|
||||
|
||||
- name: "DIR"
|
||||
file:
|
||||
path: "{{item.git.dest}}"
|
||||
state: directory
|
||||
owner: "ruby"
|
||||
group: "ruby"
|
||||
|
||||
|
||||
- name: Clone GIT
|
||||
become_user: "ruby"
|
||||
- name: "cloning git repository from {{site.git.repo}}"
|
||||
git:
|
||||
repo: "{{item.git.repo}}"
|
||||
dest: "{{item.git.dest}}"
|
||||
repo: "{{site.git.repo}}"
|
||||
dest: "{{site.dest}}"
|
||||
|
||||
|
||||
- name: ruby init
|
||||
command: 'echo "$PATH"'
|
||||
become_user: "ruby"
|
||||
changed_when: false
|
||||
args:
|
||||
chdir: "{{item.git.dest}}"
|
||||
chdir: "{{site.dest}}"
|
||||
environment:
|
||||
PATH: "{{ rvm1_install_path }}/wrappers/default:{{ ansible_env.PATH }}"
|
||||
register: out
|
||||
|
||||
|
||||
- name: run_initscript
|
||||
command: '../{{site.script}}'
|
||||
args:
|
||||
chdir: "{{site.dest}}"
|
||||
register: out
|
||||
environment:
|
||||
PATH: "{{ rvm1_install_path }}/bin:{{ rvm1_install_path }}/wrappers/ruby-{{site.ruby}}@{{site.gemset}}:{{ ansible_env.PATH }}"
|
||||
|
||||
- debug: msg="{{ out.stdout_lines }}"
|
||||
|
||||
- name: ls
|
||||
command: ls .
|
||||
become_user: "ruby"
|
||||
args:
|
||||
chdir: "{{item.git.dest}}"
|
||||
register: out
|
||||
|
||||
- debug: msg="{{ out.stdout_lines }}"
|
||||
|
||||
- shell: ./initscript.sh
|
||||
become_user: "ruby"
|
||||
args:
|
||||
chdir: "{{item.git.dest}}"
|
||||
register: output
|
||||
when: not(item.ruby_init is undefined) and item.ruby_init
|
||||
|
||||
- debug:
|
||||
msg:"{{output}}"
|
||||
|
||||
- name: ruby init
|
||||
command: 'echo initscript.sh | /bin/bash --login'
|
||||
become_user: "ruby"
|
||||
args:
|
||||
chdir: "{{item.git.dest}}"
|
||||
register: output
|
||||
when: not(item.ruby_init is undefined) and item.ruby_init
|
||||
|
||||
|
||||
|
||||
- debug:
|
||||
msg:"{{output}}"
|
||||
- include_tasks: fetsite.yml
|
||||
when: not(site.ruby_init is undefined) and site.ruby_init
|
||||
|
||||
78
templates/fetsite/etherpad-lite.j2
Executable file
78
templates/fetsite/etherpad-lite.j2
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: etherpad-lite
|
||||
# Required-Start: $local_fs $remote_fs $network $syslog
|
||||
# Required-Stop: $local_fs $remote_fs $network $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: starts etherpad lite
|
||||
# Description: starts etherpad lite using start-stop-daemon
|
||||
### END INIT INFO
|
||||
|
||||
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
|
||||
LOGFILE="/var/log/etherpad-lite/etherpad-lite.log"
|
||||
EPLITE_DIR="/opt/etherpad/etherpad-lite"
|
||||
EPLITE_BIN="bin/run.sh"
|
||||
USER="fetsite"
|
||||
GROUP="fetsite"
|
||||
DESC="Etherpad Lite"
|
||||
NAME="etherpad-lite"
|
||||
|
||||
set -e
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
start() {
|
||||
echo "Starting $DESC... "
|
||||
|
||||
start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true
|
||||
echo "done"
|
||||
}
|
||||
|
||||
#We need this function to ensure the whole process tree will be killed
|
||||
killtree() {
|
||||
local _pid=$1
|
||||
local _sig=${2-TERM}
|
||||
for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
|
||||
killtree ${_child} ${_sig}
|
||||
done
|
||||
kill -${_sig} ${_pid}
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo "Stopping $DESC... "
|
||||
if test -f /var/run/$NAME.pid; then
|
||||
while test -d /proc/$(cat /var/run/$NAME.pid); do
|
||||
killtree $(cat /var/run/$NAME.pid) 15
|
||||
sleep 0.5
|
||||
done
|
||||
rm /var/run/$NAME.pid
|
||||
fi
|
||||
echo "done"
|
||||
}
|
||||
|
||||
status() {
|
||||
status_of_proc -p /var/run/$NAME.pid "" "etherpad-lite" && exit 0 || exit $?
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $NAME {start|stop|restart|status}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
119
templates/fetsite/unicorn.j2
Executable file
119
templates/fetsite/unicorn.j2
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# init.d script for single or multiple unicorn installations. Expects at least one .conf
|
||||
# file in /etc/unicorn
|
||||
#
|
||||
# Modified by jay@gooby.org http://github.com/jaygooby
|
||||
# based on http://gist.github.com/308216 by http://github.com/mguterl
|
||||
#
|
||||
## A sample /etc/unicorn/my_app.conf
|
||||
##
|
||||
## RAILS_ENV=production
|
||||
## RAILS_ROOT=/var/apps/www/my_app/current
|
||||
#
|
||||
# This configures a unicorn master for your app at /var/apps/www/my_app/current running in
|
||||
# production mode. It will read config/unicorn.rb for further set up.
|
||||
#
|
||||
# You should ensure different ports or sockets are set in each config/unicorn.rb if
|
||||
# you are running more than one master concurrently.
|
||||
#
|
||||
# If you call this script without any config parameters, it will attempt to run the
|
||||
# init command for all your unicorn configurations listed in /etc/unicorn/*.conf
|
||||
#
|
||||
# /etc/init.d/unicorn start # starts all unicorns
|
||||
#
|
||||
# If you specify a particular config, it will only operate on that one
|
||||
#
|
||||
# /etc/init.d/unicorn start /etc/unicorn/my_app.conf
|
||||
|
||||
set -e
|
||||
|
||||
sig () {
|
||||
test -s "$PID" && kill -$1 `cat "$PID"`
|
||||
}
|
||||
|
||||
oldsig () {
|
||||
test -s "$OLD_PID" && kill -$1 `cat "$OLD_PID"`
|
||||
}
|
||||
|
||||
cmd () {
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
sig 0 && echo >&2 "Already running" && exit 0
|
||||
echo "Starting"
|
||||
$CMD
|
||||
;;
|
||||
stop)
|
||||
sig QUIT && echo "Stopping" && exit 0
|
||||
echo >&2 "Not running"
|
||||
;;
|
||||
force-stop)
|
||||
sig TERM && echo "Forcing a stop" && exit 0
|
||||
echo >&2 "Not running"
|
||||
;;
|
||||
restart)
|
||||
sig USR2 && echo "Starting new process" && sleep 5 && oldsig QUIT && echo "Killing old master" `cat $OLD_PID` && exit 0
|
||||
echo >&2 "Couldn't reload, starting '$CMD' instead"
|
||||
$CMD
|
||||
;;
|
||||
reload)
|
||||
sig HUP && echo "Reloading Config" && exit 0
|
||||
echo >&2 "Couldn't reload, starting '$CMD' instead"
|
||||
$CMD
|
||||
;;
|
||||
upgrade)
|
||||
sig USR2 && echo Upgraded && exit 0
|
||||
echo >&2 "Couldn't upgrade, starting '$CMD' instead"
|
||||
$CMD
|
||||
;;
|
||||
rotate)
|
||||
sig USR1 && echo rotated logs OK && exit 0
|
||||
echo >&2 "Couldn't rotate logs" && exit 1
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Usage: $0 <start|stop|restart|upgrade|rotate|force-stop>"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
setup () {
|
||||
|
||||
echo -n "$RAILS_ROOT: "
|
||||
cd $RAILS_ROOT || exit 1
|
||||
export PID=$RAILS_ROOT/tmp/pids/unicorn.pid
|
||||
export OLD_PID="$PID.oldbin"
|
||||
export HOME=$RAILS_ROOT
|
||||
export RAILS_ENV=$RAILS_ENV
|
||||
CMD="{{ rvm1_install_path }}/wrappers/{{site.ruby}}@{{site.gemset}}/unicorn_rails -c config/unicorn.rb -E $RAILS_ENV -D"
|
||||
CMD="{{ rvm1_install_path }}/wrappers/{{site.ruby}}@{{site.gemset}}/bundle exec unicorn_rails -c config/unicorn.rb -E $RAILS_ENV -D"
|
||||
|
||||
|
||||
}
|
||||
|
||||
start_stop () {
|
||||
|
||||
# either run the start/stop/reload/etc command for every config under /etc/unicorn
|
||||
# or just do it for a specific one
|
||||
|
||||
# $1 contains the start/stop/etc command
|
||||
# $2 if it exists, should be the specific config we want to act on
|
||||
if [ $2 ]; then
|
||||
. $2
|
||||
setup
|
||||
cmd $1
|
||||
else
|
||||
for CONFIG in /etc/unicorn/*.conf; do
|
||||
# import the variables
|
||||
. $CONFIG
|
||||
setup
|
||||
|
||||
# run the start/stop/etc command
|
||||
cmd $1
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
ARGS="$1 $2"
|
||||
start_stop $ARGS
|
||||
14
templates/ruby_fetsite.j2
Normal file
14
templates/ruby_fetsite.j2
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
echo "sdf"
|
||||
echo "{{site}}"
|
||||
source ~/.rvm/scripts/rvm
|
||||
source $({{rvm1_rvm}} {{site.ruby}} do rvm gemset create {{site.gemset}})
|
||||
|
||||
source $({{rvm1_rvm}} {{site.ruby}}@{{site.gemset}} do rvm env --path)
|
||||
which ruby
|
||||
gem install bundler
|
||||
bundle install
|
||||
rvm gemset list
|
||||
ruby -v
|
||||
|
||||
#ruby -v
|
||||
@@ -21,3 +21,4 @@ rvm1_symlink_bundler_binaries:
|
||||
- 'bundler'
|
||||
|
||||
rvm1_symlink_to: '/usr/local/bin'
|
||||
rvm1_ruby_install_flags: "--autolibs={{rvm1_autolib_mode}}"
|
||||
Reference in New Issue
Block a user