diff --git a/README.md b/README.md index 3637db8..84013a8 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,64 @@ Role Name ========= -A brief description of the role goes here. - -Requirements ------------- - -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. +A role that installs the eXist-db service, Role Variables -------------- -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. +The most important variables are listed below: + +``` yaml +exist_db_major: 5 +exist_db_minor: 2 +exist_db_patch: 0 +exist_db_http_port: 8080 + +exist_db_home: '/srv/existdb' +exist_db_data_dir: '{{ exist_db_home }}/data' +exist_db_journal_dir: '{{ exist_db_home }}/data-journal' +exist_db_backup_dir: '{{ exist_db_home }}/data-backups' +exist_db_bin_backup_dir: '{{ exist_db_home }}/data/backup' +exist_db_base_dir: '{{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}' +exist_db_logdir: '/var/log/exist-db' +#exist_db_conf_dir: '/srv/existdb/etc' +exist_db_conf_dir: '{{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/etc' + +# Always express it in 'm' (MegaBytes) +exist_db_min_java_heap: '512' +exist_db_max_java_heap: '{{ exist_db_min_java_heap }}' +# exist_db_max_java_heap / 3 +exist_db_cache_size: '170' +exist_db_file_encoding: 'UTF-8' +exist_db_java_opts: "-Xms{{ exist_db_min_java_heap }}m -Xmx{{ exist_db_max_java_heap }}m -server -Djava.awt.headless=true -Dfile.encoding={{ exist_db_file_encoding }}" + +exist_db_consistency_enabled: True +exist_db_check_cron: "0 0 0/3 * * ?" +exist_db_max_backups_enabled: 6 +exist_db_backups_enabled: True +exist_db_incremental_backups_enabled: "yes" +exist_db_backup_cron: "0 0 0/12 * * ?" + +# Only works with deb based distributions and when our basic-system-setup role is used by the playbook +exist_db_tmpreaper_install: True +exist_db_tmpreaper_dirs: '{{ exist_db_bin_backup_dir }}/. {{ exist_db_backup_dir }}/.' +exist_db_tmpreaper_time: '10d' + +# Setup nginx in front of the service +exist_db_nginx_setup: True +exist_db_nginx_use_common_virthost: True +exist_db_nginx_define_x_real_ip: True +exist_db_nginx_set_original_uri: True +exist_db_nginx_virtualhost_name: '{{ ansible_fqdn }}' +exist_db_nginx_server_name: '{{ exist_db_nginx_virtualhost_name }}' +exist_db_nginx_server_aliases: '' +nginx_virthosts: '{{ exist_db_nginx_virthosts }}' +``` Dependencies ------------ -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers - roles: - - { role: username.rolename, x: 42 } +None License ------- @@ -35,4 +68,4 @@ EUPL-1.2 Author Information ------------------ -An optional section for the role authors to include contact information, or a website (HTML is not allowed). +Andrea Dell'Amico, diff --git a/defaults/main.yml b/defaults/main.yml index 95d3c70..1274663 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,45 @@ --- -# defaults file for ansible-role-template \ No newline at end of file +exist_db_major: 5 +exist_db_minor: 2 +exist_db_patch: 0 +exist_db_http_port: 8080 + +exist_db_home: '/srv/existdb' +exist_db_data_dir: '{{ exist_db_home }}/data' +exist_db_journal_dir: '{{ exist_db_home }}/data-journal' +exist_db_backup_dir: '{{ exist_db_home }}/data-backups' +exist_db_bin_backup_dir: '{{ exist_db_home }}/data/backup' +exist_db_base_dir: '{{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}' +exist_db_logdir: '/var/log/exist-db' +#exist_db_conf_dir: '/srv/existdb/etc' +exist_db_conf_dir: '{{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/etc' + +# Always express it in 'm' (MegaBytes) +exist_db_min_java_heap: '512' +exist_db_max_java_heap: '{{ exist_db_min_java_heap }}' +# exist_db_max_java_heap / 3 +exist_db_cache_size: '170' +exist_db_file_encoding: 'UTF-8' +exist_db_java_opts: "-Xms{{ exist_db_min_java_heap }}m -Xmx{{ exist_db_max_java_heap }}m -server -Djava.awt.headless=true -Dfile.encoding={{ exist_db_file_encoding }}" + +exist_db_consistency_enabled: True +exist_db_check_cron: "0 0 0/3 * * ?" +exist_db_max_backups_enabled: 6 +exist_db_backups_enabled: True +exist_db_incremental_backups_enabled: "yes" +exist_db_backup_cron: "0 0 0/12 * * ?" + +# Only works with deb based distributions and when our basic-system-setup role is used by the playbook +exist_db_tmpreaper_install: True +exist_db_tmpreaper_dirs: '{{ exist_db_bin_backup_dir }}/. {{ exist_db_backup_dir }}/.' +exist_db_tmpreaper_time: '10d' + +# Setup nginx in front of the service +exist_db_nginx_setup: True +exist_db_nginx_use_common_virthost: True +exist_db_nginx_define_x_real_ip: True +exist_db_nginx_set_original_uri: True +exist_db_nginx_virtualhost_name: '{{ ansible_fqdn }}' +exist_db_nginx_server_name: '{{ exist_db_nginx_virtualhost_name }}' +exist_db_nginx_server_aliases: '' +nginx_virthosts: '{{ exist_db_nginx_virthosts }}' diff --git a/handlers/main.yml b/handlers/main.yml index 27474e0..5d26c16 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,2 +1,3 @@ --- -# handlers file for ansible-role-template \ No newline at end of file +- name: Restart existdb + service: name=exist-db state=started enabled=yes diff --git a/meta/main.yml b/meta/main.yml index 81bda14..e3e8932 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,46 +1,35 @@ galaxy_info: - author: your name - description: your description - company: your company (optional) + author: Andrea Dell'Amico + description: Systems Architect + company: ISTI-CNR - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - issue_tracker_url: https://support.d4science.org/projects/automatic-provisioning/issues + issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning - license: EUPL-1.2 + license: EUPL 1.2+ min_ansible_version: 2.8 - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - # Optionally specify the branch Galaxy will use when accessing the GitHub - # repo for this role. During role install, if no tags are available, - # Galaxy will use this branch. During import Galaxy will access files on - # this branch. If Travis integration is configured, only notifications for this - # branch will be accepted. Otherwise, in all cases, the repo's default branch - # (usually master) will be used. - #github_branch: - - # - # Provide a list of supported platforms, and for each platform a list of versions. - # If you don't wish to enumerate all versions for a particular platform, use 'all'. # To view available platforms and versions (or releases), visit: # https://galaxy.ansible.com/api/v1/platforms/ # platforms: - - name: Ubuntu - versions: - - bionic + - name: Ubuntu + versions: + - bionic + - name: EL + versions: + - 7 - galaxy_tags: [] - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. + galaxy_tags: + - exist-db -dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. \ No newline at end of file +dependencies: + - src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-openjdk.git + version: master + name: openjdk + state: latest + - src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-nginx.git + version: master + name: nginx + state: latest + when: nginx_setup diff --git a/tasks/main.yml b/tasks/main.yml index 53c6cae..7f44178 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,77 @@ --- -# tasks file for ansible-role-template \ No newline at end of file +- name: Create the exist-db user and the directory tree + block: + - name: Create the exist-db user + user: name={{ exist_db_user }} home={{ exist_db_home }} comment="eXist-db Service Account" createhome=no shell=/usr/sbin/nologin system=yes + + - name: Create the exist-db base path + file: dest={{ item }} state=directory mode=0750 owner=root group={{ exist_db_group }} + with_items: + - '{{ exist_db_home }}' + - '{{ exist_db_home }}/distribution' + - '{{ exist_db_conf_dir }}' + + - name: Create the exist-db directory tree + file: dest={{ item }} state=directory mode=0750 owner={{ exist_db_user }} group={{ exist_db_group }} + with_items: + - '{{ exist_db_data_dir }}' + - '{{ exist_db_journal_dir }}' + - '{{ exist_db_backup_dir }}' + - '{{ exist_db_logdir }}' + + - name: Link the log and data directories from the exist distribution directory + file: dest={{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/{{ item }} state=absent + with_items: + - 'data' + - 'logs' + + - name: Link the log directory into the exist distribution directory + file: src={{ exist_db_logdir }} dest={{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/logs state=link + + - name: Link the data directory into the exist distribution directory + file: src={{ exist_db_data_dir }} dest={{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/data state=link + + tags: [ 'exist-db', 'exist_db' ] + +- name: Download and unpack the eXist DB distribution + block: + - name: Download the eXist DB archive + get_url: url={{ exist_db_distribution }} dest=/srv/exist-distribution-{{ exist_db_version }}-unix.tar.bz2 + + - name: Unarchive the eXist DB distribution + unarchive: src=/srv/exist-distribution-{{ exist_db_version }}-unix.tar.bz2 dest={{ exist_db_home }}/distribution remote_src=yes owner=root group=root + args: + creates: '{{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/lib' + + tags: [ 'exist-db', 'exist_db' ] + +- name: Configure the eXistDB service + block: + - name: Install the changes to the configuration files in the custom etc/ directory + template: src={{ item }}.j2 dest={{ exist_db_conf_dir }}/{{ item }} + with_items: + - 'conf.xml' + - 'log4j2.xml' + notify: Restart existdb + + - name: Install the startup scripts + template: src={{ item }}.j2 dest={{ exist_db_home }}/distribution/{{ exist_db_distribution_dir }}/bin/{{ item }} owner=root group=root mode=0755 + with_items: + - 'startup.sh' + - 'shutdown.sh' + - 'backup.sh' + - 'client.sh' + - 'export.sh' + + - name: Install the exist-db systemd unit + template: src=exist-db.service.j2 dest=/lib/systemd/system/exist-db.service owner=root group=root mode=0644 + register: existdb_unit_install + + - name: Reload the systemd configuration + systemd: daemon_reload=yes + when: existdb_unit_install is changed + + - name: Ensure that the eXistDB service is running and enabled + service: name=exist-db state=started enabled=yes + + tags: [ 'exist-db', 'exist_db', 'exist_db_conf' ] diff --git a/templates/backup.sh.j2 b/templates/backup.sh.j2 new file mode 100755 index 0000000..f03dae4 --- /dev/null +++ b/templates/backup.sh.j2 @@ -0,0 +1,86 @@ +#!/usr/bin/env sh +# eXist Open Source Native XML Database +# Copyright (C) 2019 The eXist-db Project +# info@exist-db.org +# http://www.exist-db.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` +#BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd` +BASEDIR="{{ exist_db_base_dir }}" + +# Reset the REPO variable. If you need to influence this use the environment setup file. +REPO= + +# If a specific java binary isn't specified search for the standard 'java' binary +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java` + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." 1>&2 + echo " We cannot execute $JAVACMD" 1>&2 + exit 1 +fi + +if [ -z "$REPO" ] +then + REPO="$BASEDIR"/lib +fi + +CLASSPATH="$BASEDIR"/etc:"$REPO"/appassembler-booter-2.1.0.jar:"$REPO"/appassembler-model-2.1.0.jar:"$REPO"/plexus-utils-3.2.0.jar:"$REPO"/stax-api-1.0.1.jar:"$REPO"/stax-1.1.1-dev.jar + +ENDORSED_DIR= +if [ -n "$ENDORSED_DIR" ] ; then + CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH +fi + +if [ -n "$CLASSPATH_PREFIX" ] ; then + CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH +fi + +exec "$JAVACMD" $JAVA_OPTS -Xms128m -Dfile.encoding=UTF-8 -Dlog4j.configurationFile={{ exist_db_conf_dir }}/log4j2.xml -Dexist.home="$BASEDIR" -Dexist.configurationFile={{ exist_db_conf_dir }}/conf.xml -Djetty.home="$BASEDIR" -Dexist.jetty.config="$BASEDIR"/etc/jetty/standard.enabled-jetty-configs \ + -classpath "$CLASSPATH" \ + -Dapp.name="backup" \ + -Dapp.pid="$$" \ + -Dapp.repo="$REPO" \ + -Dapp.home="$BASEDIR" \ + -Dbasedir="$BASEDIR" \ + org.codehaus.mojo.appassembler.booter.AppassemblerBooter \ + "$@" diff --git a/templates/client.sh.j2 b/templates/client.sh.j2 new file mode 100755 index 0000000..405ae02 --- /dev/null +++ b/templates/client.sh.j2 @@ -0,0 +1,85 @@ +#!/usr/bin/env sh +# eXist Open Source Native XML Database +# Copyright (C) 2019 The eXist-db Project +# info@exist-db.org +# http://www.exist-db.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` +BASEDIR="{{ exist_db_base_dir }}" + +# Reset the REPO variable. If you need to influence this use the environment setup file. +REPO= + +# If a specific java binary isn't specified search for the standard 'java' binary +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java` + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." 1>&2 + echo " We cannot execute $JAVACMD" 1>&2 + exit 1 +fi + +if [ -z "$REPO" ] +then + REPO="$BASEDIR"/lib +fi + +CLASSPATH="$BASEDIR"/etc:"$REPO"/appassembler-booter-2.1.0.jar:"$REPO"/appassembler-model-2.1.0.jar:"$REPO"/plexus-utils-3.2.0.jar:"$REPO"/stax-api-1.0.1.jar:"$REPO"/stax-1.1.1-dev.jar + +ENDORSED_DIR= +if [ -n "$ENDORSED_DIR" ] ; then + CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH +fi + +if [ -n "$CLASSPATH_PREFIX" ] ; then + CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH +fi + +exec "$JAVACMD" $JAVA_OPTS -Xms128m -Dfile.encoding=UTF-8 -Dlog4j.configurationFile={{ exist_db_conf_dir }}/log4j2.xml -Dexist.home="$BASEDIR" -Dexist.configurationFile={{ exist_db_conf_dir }}/conf.xml -Djetty.home="$BASEDIR" -Dexist.jetty.config="$BASEDIR"/etc/jetty/standard.enabled-jetty-configs \ + -classpath "$CLASSPATH" \ + -Dapp.name="client" \ + -Dapp.pid="$$" \ + -Dapp.repo="$REPO" \ + -Dapp.home="$BASEDIR" \ + -Dbasedir="$BASEDIR" \ + org.codehaus.mojo.appassembler.booter.AppassemblerBooter \ + "$@" diff --git a/templates/conf.xml.j2 b/templates/conf.xml.j2 new file mode 100644 index 0000000..d7897ce --- /dev/null +++ b/templates/conf.xml.j2 @@ -0,0 +1,1040 @@ +{% raw %} + + + + +{% endraw %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endraw %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endraw %} +{% if exist_db_consistency_enabled %} + + + + + + + +{% endif %} +{% raw %} + +{% endraw %} +{% if exist_db_consistency_enabled %} + + + + + + + +{% endif %} +{% raw %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endraw %} \ No newline at end of file diff --git a/templates/exist-db.service.j2 b/templates/exist-db.service.j2 new file mode 100644 index 0000000..e908c74 --- /dev/null +++ b/templates/exist-db.service.j2 @@ -0,0 +1,20 @@ +[Unit] +Description=eXist-db {{ exist_db_version }} Server +Documentation=http://www.exist-db.org/exist/apps/doc/documentation +After=syslog.target network.target + +[Service] +#Type=forking +Type=simple +SyslogIdentifier=existdb +User={{ exist_db_user }} +Group={{ exist_db_group }} +ExecStart={{ exist_db_base_dir }}/bin/startup.sh +ExecStop={{ exist_db_base_dir }}/bin/shutdown.sh +Restart=on-failure +RestartSec=30s +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target + diff --git a/templates/export.sh.j2 b/templates/export.sh.j2 new file mode 100755 index 0000000..90c1a20 --- /dev/null +++ b/templates/export.sh.j2 @@ -0,0 +1,85 @@ +#!/usr/bin/env sh +# eXist Open Source Native XML Database +# Copyright (C) 2019 The eXist-db Project +# info@exist-db.org +# http://www.exist-db.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` +BASEDIR="{{ exist_db_base_dir }}" + +# Reset the REPO variable. If you need to influence this use the environment setup file. +REPO= + +# If a specific java binary isn't specified search for the standard 'java' binary +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java` + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." 1>&2 + echo " We cannot execute $JAVACMD" 1>&2 + exit 1 +fi + +if [ -z "$REPO" ] +then + REPO="$BASEDIR"/lib +fi + +CLASSPATH="$BASEDIR"/etc:"$REPO"/appassembler-booter-2.1.0.jar:"$REPO"/appassembler-model-2.1.0.jar:"$REPO"/plexus-utils-3.2.0.jar:"$REPO"/stax-api-1.0.1.jar:"$REPO"/stax-1.1.1-dev.jar + +ENDORSED_DIR= +if [ -n "$ENDORSED_DIR" ] ; then + CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH +fi + +if [ -n "$CLASSPATH_PREFIX" ] ; then + CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH +fi + +exec "$JAVACMD" $JAVA_OPTS -Xms128m -Dfile.encoding=UTF-8 -Dlog4j.configurationFile={{ exist_db_conf_dir }}/log4j2.xml -Dexist.home="$BASEDIR" -Dexist.configurationFile={{ exist_db_conf_dir }}/conf.xml -Djetty.home="$BASEDIR" -Dexist.jetty.config="$BASEDIR"/etc/jetty/standard.enabled-jetty-configs \ + -classpath "$CLASSPATH" \ + -Dapp.name="export" \ + -Dapp.pid="$$" \ + -Dapp.repo="$REPO" \ + -Dapp.home="$BASEDIR" \ + -Dbasedir="$BASEDIR" \ + org.codehaus.mojo.appassembler.booter.AppassemblerBooter \ + "$@" diff --git a/templates/log4j2.xml.j2 b/templates/log4j2.xml.j2 new file mode 100644 index 0000000..96f708b --- /dev/null +++ b/templates/log4j2.xml.j2 @@ -0,0 +1,252 @@ + + + + {{ exist_db_logdir }} +{% raw %} + 10MB + 14 + %d{yyyyMMddHHmmss} + %d [%t] %-5p (%F [%M]:%L) - %m %n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endraw %} diff --git a/templates/shutdown.sh.j2 b/templates/shutdown.sh.j2 new file mode 100755 index 0000000..87cbbb7 --- /dev/null +++ b/templates/shutdown.sh.j2 @@ -0,0 +1,86 @@ +#!/usr/bin/env sh +# eXist Open Source Native XML Database +# Copyright (C) 2019 The eXist-db Project +# info@exist-db.org +# http://www.exist-db.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` +#BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd` +BASEDIR="{{ exist_db_base_dir }}" + +# Reset the REPO variable. If you need to influence this use the environment setup file. +REPO= + +# If a specific java binary isn't specified search for the standard 'java' binary +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java` + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." 1>&2 + echo " We cannot execute $JAVACMD" 1>&2 + exit 1 +fi + +if [ -z "$REPO" ] +then + REPO="$BASEDIR"/lib +fi + +CLASSPATH="$BASEDIR"/etc:"$REPO"/appassembler-booter-2.1.0.jar:"$REPO"/appassembler-model-2.1.0.jar:"$REPO"/plexus-utils-3.2.0.jar:"$REPO"/stax-api-1.0.1.jar:"$REPO"/stax-1.1.1-dev.jar + +ENDORSED_DIR= +if [ -n "$ENDORSED_DIR" ] ; then + CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH +fi + +if [ -n "$CLASSPATH_PREFIX" ] ; then + CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH +fi + +exec "$JAVACMD" $JAVA_OPTS {{ exist_db_java_opts }} -Dlog4j.configurationFile={{ exist_db_conf_dir }}/log4j2.xml -Dexist.home="$BASEDIR" -Dexist.configurationFile={{ exist_db_conf_dir }}/conf.xml -Djetty.home="$BASEDIR" -Dexist.jetty.config="$BASEDIR"/etc/jetty/standard.enabled-jetty-configs \ + -classpath "$CLASSPATH" \ + -Dapp.name="shutdown" \ + -Dapp.pid="$$" \ + -Dapp.repo="$REPO" \ + -Dapp.home="$BASEDIR" \ + -Dbasedir="$BASEDIR" \ + org.codehaus.mojo.appassembler.booter.AppassemblerBooter \ + "$@" diff --git a/templates/startup.sh.j2 b/templates/startup.sh.j2 new file mode 100755 index 0000000..5cd0e3c --- /dev/null +++ b/templates/startup.sh.j2 @@ -0,0 +1,86 @@ +#!/usr/bin/env sh +# eXist Open Source Native XML Database +# Copyright (C) 2019 The eXist-db Project +# info@exist-db.org +# http://www.exist-db.org +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + + +# resolve links - $0 may be a softlink +PRG="$0" + +while [ -h "$PRG" ]; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`/"$link" + fi +done + +PRGDIR=`dirname "$PRG"` +#BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd` +BASEDIR="{{ exist_db_base_dir }}" + +# Reset the REPO variable. If you need to influence this use the environment setup file. +REPO= + +# If a specific java binary isn't specified search for the standard 'java' binary +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD=`which java` + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." 1>&2 + echo " We cannot execute $JAVACMD" 1>&2 + exit 1 +fi + +if [ -z "$REPO" ] +then + REPO="$BASEDIR"/lib +fi + +CLASSPATH="$BASEDIR"/etc:"$REPO"/appassembler-booter-2.1.0.jar:"$REPO"/appassembler-model-2.1.0.jar:"$REPO"/plexus-utils-3.2.0.jar:"$REPO"/stax-api-1.0.1.jar:"$REPO"/stax-1.1.1-dev.jar + +ENDORSED_DIR= +if [ -n "$ENDORSED_DIR" ] ; then + CLASSPATH=$BASEDIR/$ENDORSED_DIR/*:$CLASSPATH +fi + +if [ -n "$CLASSPATH_PREFIX" ] ; then + CLASSPATH=$CLASSPATH_PREFIX:$CLASSPATH +fi + +exec "$JAVACMD" $JAVA_OPTS {{ exist_db_java_opts }} -Dlog4j.configurationFile={{ exist_db_conf_dir }}/log4j2.xml -Dexist.home="$BASEDIR" -Dexist.configurationFile={{ exist_db_conf_dir }}/conf.xml -Djetty.home="$BASEDIR" -Dexist.jetty.config="$BASEDIR"/etc/jetty/standard.enabled-jetty-configs \ + -classpath "$CLASSPATH" \ + -Dapp.name="startup" \ + -Dapp.pid="$$" \ + -Dapp.repo="$REPO" \ + -Dapp.home="$BASEDIR" \ + -Dbasedir="$BASEDIR" \ + org.codehaus.mojo.appassembler.booter.AppassemblerBooter \ + "$@" diff --git a/vars/main.yml b/vars/main.yml index 3808477..49235cb 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,31 @@ --- -# vars file for ansible-role-template \ No newline at end of file +exist_db_user: existdb +exist_db_group: '{{ exist_db_user }}' +exist_db_version: '{{ exist_db_major }}.{{ exist_db_minor }}.{{ exist_db_patch }}' +exist_db_distribution_dir: 'exist-distribution-{{ exist_db_version }}' +exist_db_distribution: 'https://bintray.com/existdb/releases/download_file?file_path={{ exist_db_distribution_dir }}-unix.tar.bz2' + +tmpreaper_install: '{{ exist_db_tmpreaper_install }}' +tmpreaper_extra_dirs: '{{ exist_db_tmpreaper_dirs }}' +tmpreaper_time: '{{ exist_db_tmpreaper_time }}' + +nginx_setup: '{{ exist_db_nginx_setup }}' +nginx_use_common_virthost: '{{ exist_db_nginx_use_common_virthost }}' +nginx_define_x_real_ip: '{{ exist_db_nginx_define_x_real_ip }}' +nginx_set_original_uri: '{{ exist_db_nginx_set_original_uri }}' + +exist_db_nginx_virthosts: + - virthost_name: '{{ exist_db_nginx_virtualhost_name }}' + listen: "{{ http_port | default('80') }}" + server_name: '{{ exist_db_nginx_server_name }}' + server_aliases: '{{ exist_db_nginx_server_aliases }}' + ssl_enabled: True + ssl_only: True + ssl_letsencrypt_certs: '{{ nginx_letsencrypt_managed }}' + root: /usr/share/nginx/html/ + server_tokens: 'off' + websockets: False + proxy_standard_setup: True + locations: + - location: / + target: http://localhost:{{ exist_db_http_port }}/