Commit 39ca8c0e authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

init

parents
Pipeline #922 skipped
saem formula
================
===============
saemref-formula
===============
Available states
================
.. contents::
:local:
``saemref``
-----------
``saemref.db-create``
---------------------
saemref:
instance:
name: saemref
user: saemref
db:
host: ""
port: ""
name: saemref
user: saemref
pass: saemref
admin:
login: admin
pass: admin
{% from "saemref/map.jinja" import saemref with context %}
include:
- saemref
cubicweb-initdb:
cmd.run:
- name: cubicweb-ctl db-create -a {{ saemref.instance.name }}
- user: {{ saemref.instance.user }}
- env:
CW_MODE: user
# -*- coding: utf-8 -*-
# vim: ft=yaml
saemref:
instance:
name: saemref
user: saemref
db:
host: ""
port: ""
name: saemref
user: saemref
pass: saemref
admin:
login: admin
pass: admin
# -*- coding: utf-8 -*-
# vim: ft=jinja et
{% from "saemref/map.jinja" import saemref with context %}
include:
- epel
logilab_extranet:
pkgrepo.managed:
- humanname: Logilab extranet BRDX $releasever $basearch
- baseurl: https://extranet.logilab.fr/static/BRDX/rpms/epel-$releasever-$basearch
- gpgcheck: 0
cubicweb-saem-ref:
pkg.installed:
- require:
- pkgrepo: logilab_extranet
create-saemref-user:
user.present:
- name: {{ saemref.instance.user }}
cubicweb-create:
cmd.run:
- name: cubicweb-ctl create -Sa saem_ref {{ saemref.instance.name }}
- creates: /home/{{ saemref.instance.user }}/etc/cubicweb.d/{{ saemref.instance.name }}
- user: {{ saemref.instance.user }}
- env:
CW_MODE: user
- require:
- pkg: cubicweb-saem-ref
- user: {{ saemref.instance.user }}
cubicweb-config:
file.managed:
- name: /home/{{ saemref.instance.user }}/etc/cubicweb.d/{{ saemref.instance.name }}/sources
- source: salt://saemref/templates/sources.j2
- template: jinja
- require:
- cmd: cubicweb-create
python-pip:
pkg.installed
upgrade-pip:
pip.installed:
- name: pip
- upgrade: true
upgrade-setuptools:
pip.installed:
- name: setuptools
- upgrade: true
supervisor:
pip.installed
/etc/init.d/supervisor:
file.managed:
- source: salt://saemref/files/supervisor.init
/etc/supervisord.conf:
file.managed:
- source: salt://saemref/files/supervisord.conf
# -*- coding: utf-8 -*-
# vim: ft=jinja
{% import_yaml 'saemref/defaults.yaml' as default_settings %}
{% set os_family_map = salt['grains.filter_by']({
'Debian': {},
'RedHat': {},
},
grain="os_family",
merge=salt['pillar.get']('template:lookup'))
%}
{% do default_settings.saemref.update(os_family_map) %}
{% set saemref = salt['pillar.get'](
'saemref',
default=default_settings.saemref,
merge=True,
)
%}
#!/bin/sh
### BEGIN INIT INFO
# Provides: saemref
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# chkconfig header
# chkconfig: 345 97 04
# description: CubicWeb saem_ref
#
# processname: /usr/bin/cubicweb-ctl
DEBIAN_VERSION=/etc/debian_version
# Source function library.
if [ -f $DEBIAN_VERSION ]; then
break
else
. /etc/rc.d/init.d/functions
fi
# Default values (can be overridden below)
CUBICWEBCTL=/usr/bin/cubicweb-ctl
if [ -f /etc/default/saemref ]; then
. /etc/default/saemref
fi
SERVICE=saemref
PROCESS=saemref
RETVAL=0
start() {
echo -n $"Starting saemref daemon: "
if [ -e $DEBIAN_VERSION ]; then
if [ -f $LOCKFILE ]; then
echo -n "already started, lock file found"
RETVAL=1
elif $PYTHON $SALTMINION -d $MINION_ARGS >& /dev/null; then
echo -n "OK"
RETVAL=0
fi
else
if [[ ! -z "$(pidofproc -p /var/run/$SERVICE.pid $PROCESS)" ]]; then
RETVAL=$?
echo -n "already running"
else
daemon --check $SERVICE $SALTMINION -d $MINION_ARGS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SERVICE
echo
return $RETVAL
fi
fi
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stopping salt-minion daemon: "
if [ -f $SUSE_RELEASE ]; then
killproc -TERM $SALTMINION
rc_status -v
RETVAL=$?
elif [ -f $DEBIAN_VERSION ]; then
# Added this since Debian's start-stop-daemon doesn't support spawned processes
if ps -ef | grep "$PYTHON $SALTMINION" | grep -v grep | awk '{print $2}' | xargs kill &> /dev/null; then
echo -n "OK"
RETVAL=0
else
echo -n "Daemon is not started"
RETVAL=1
fi
else
killproc $PROCESS
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$SERVICE
# tidy up any rogue processes:
PROCS=`ps -ef | grep "$SALTMINION" | grep -v grep | awk '{print $2}'`
if [ -n "$PROCS" ]; then
kill $PROCS &> /dev/null
sleep 1
PROCS=`ps -ef | grep "$SALTMINION" | grep -v grep | awk '{print $2}'`
if [ -n "$PROCS" ]; then
kill -9 $PROCS &> /dev/null
fi
fi
fi
echo
}
restart() {
stop
start
}
# See how we were called.
case "$1" in
start|stop|restart)
$1
;;
status)
if [ -f $SUSE_RELEASE ]; then
echo -n "Checking for service salt-minion "
checkproc $SALTMINION
rc_status -v
elif [ -f $DEBIAN_VERSION ]; then
if [ -f $LOCKFILE ]; then
RETVAL=0
echo "salt-minion is running."
else
RETVAL=1
echo "salt-minion is stopped."
fi
else
status $PROCESS
RETVAL=$?
fi
;;
condrestart)
[ -f $LOCKFILE ] && restart || :
;;
reload)
echo "can't reload configuration, you have to restart it"
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
;;
esac
exit $RETVAL
{% from "saemref/map.jinja" import saemref with context %}
[admin]
# cubicweb manager account's login (this user will be created)
login={{ saemref.admin.login }}
# cubicweb manager account's password
password={{ saemref.admin.pass }}
[system]
# database driver (postgres, sqlite, sqlserver2005)
db-driver=postgres
# database host
db-host={{ saemref.db.host }}
# database port
db-port={{ saemref.db.port }}
# database name
db-name={{ saemref.db.name }}
# database namespace (schema) name
db-namespace=
# database user
db-user={{ saemref.db.user }}
# database password
db-password={{ saemref.db.pass }}
# database encoding
db-encoding=utf8
# set to "Trusted_Connection" if you are using SQLServer and want trusted
# authentication for the database connection
db-extra-arguments=
# sql statement timeout, in milliseconds (postgres only)
db-statement-timeout=0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment