From ce0e66391f18bc285ec67dbc47cd559ea150bd05 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 8 Nov 2018 13:32:59 +0100 Subject: [PATCH] Google openrefine role. --- google-openrefine/defaults/main.yml | 17 ++++++++ google-openrefine/handlers/main.yml | 4 ++ google-openrefine/tasks/main.yml | 40 +++++++++++++++++++ .../templates/openrefine.conf.j2 | 13 ++++++ google-openrefine/templates/refine.ini | 25 ++++++++++++ 5 files changed, 99 insertions(+) create mode 100644 google-openrefine/defaults/main.yml create mode 100644 google-openrefine/handlers/main.yml create mode 100644 google-openrefine/tasks/main.yml create mode 100644 google-openrefine/templates/openrefine.conf.j2 create mode 100644 google-openrefine/templates/refine.ini diff --git a/google-openrefine/defaults/main.yml b/google-openrefine/defaults/main.yml new file mode 100644 index 00000000..04330596 --- /dev/null +++ b/google-openrefine/defaults/main.yml @@ -0,0 +1,17 @@ +--- +openrefine_enabled: True +openrefine_major_version: 3 +openrefine_minor_version: 0 +openrefine_file_extension: 'tar.gz' +openrefine_distribution_prefix: 'openrefine' +openrefine_dist_file: '{{ openrefine_distribution_prefix }}-linux-{{ openrefine_version }}.{{ openrefine_file_extension }}' +openrefine_version: '{{ openrefine_major_version }}.{{ openrefine_minor_version }}' +openrefine_download_url: 'https://github.com/OpenRefine/OpenRefine/releases/download/{{ openrefine_version }}/{{ openrefine_dist_file }}' +openrefine_user: openrefine +openrefine_user_home: /srv/google-openrefine +openrefine_data_dir: '{{ openrefine_user_home }}/data' +openrefine_log_dir: '{{ openrefine_user_home }}/logs' +openrefine_base_dir: '{{ openrefine_user_home }}/{{ openrefine_distribution_prefix }}-{{ openrefine_version }}' +openrefine_http_port: 3333 +openrefine_java_heap: 2048m + diff --git a/google-openrefine/handlers/main.yml b/google-openrefine/handlers/main.yml new file mode 100644 index 00000000..d1ceb16b --- /dev/null +++ b/google-openrefine/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: Restart openrefine + service: name=openrefine state=restarted + diff --git a/google-openrefine/tasks/main.yml b/google-openrefine/tasks/main.yml new file mode 100644 index 00000000..56835fe6 --- /dev/null +++ b/google-openrefine/tasks/main.yml @@ -0,0 +1,40 @@ +--- +- block: + - name: Create the openrefine user + user: name={{ openrefine_user }} home={{ openrefine_user_home }} createhome=no shell=/usr/sbin/nologin system=yes + + - name: Create the openrefine home, if it does not already exist. + file: dest={{ openrefine_user_home }} owner=root group=root state=directory recurse=yes + + - name: Create the openrefine data and logs directories + file: dest={{ item }} owner={{ openrefine_user }} group={{ openrefine_user }} state=directory recurse=yes + with_items: + - '{{ openrefine_data_dir }}' + - '{{ openrefine_log_dir }}' + + - name: Download openrefine + unarchive: remote_src=yes src={{ openrefine_download_url }} dest={{ openrefine_user_home }} + args: + creates: '{{ openrefine_user_home }}/{{ openrefine_distribution_prefix }}-{{ openrefine_version }}' + + - name: Install the openrefine configuration + template: src=refine.ini dest={{ openrefine_user_home }}/{{ openrefine_distribution_prefix }}-{{ openrefine_version }}/refine.ini owner=root group=root mode=0644 + notify: Restart openrefine + + - name: Install the openrefine upstart init script + template: src=openrefine.conf.j2 dest=/etc/init/openrefine.conf owner=root group=root mode=0644 + when: ansible_service_mgr != 'systemd' + + - name: Ensure that the service is running and enabled + service: name=openrefine state=started enabled=yes + + when: openrefine_enabled + tags: [ 'openrefine', 'google_openrefine' ] + +- block: + + - name: Ensure that the service is running and enabled + service: name=openrefine state=stopped enabled=no + + when: not openrefine_enabled + tags: [ 'openrefine', 'google_openrefine' ] \ No newline at end of file diff --git a/google-openrefine/templates/openrefine.conf.j2 b/google-openrefine/templates/openrefine.conf.j2 new file mode 100644 index 00000000..1995ee31 --- /dev/null +++ b/google-openrefine/templates/openrefine.conf.j2 @@ -0,0 +1,13 @@ +description "Google OpenRefine server" +start on (local-filesystems and net-device-up IFACE!=lo) +stop on runlevel [016] + +respawn +respawn limit 10 5 +setuid {{ openrefine_user }} +setgid {{ openrefine_user }} + +script + chdir {{ openrefine_base_dir }} + exec ./refine > {{ openrefine_log_dir }}/openrefine.log 2>&1 +end script diff --git a/google-openrefine/templates/refine.ini b/google-openrefine/templates/refine.ini new file mode 100644 index 00000000..589cf284 --- /dev/null +++ b/google-openrefine/templates/refine.ini @@ -0,0 +1,25 @@ +# NOTE: This file is not read if you run the Refine executable directly +# It is only read of you use the refine shell script or refine.bat + +no_proxy="localhost,127.0.0.1" +REFINE_PORT={{ openrefine_http_port }} +#REFINE_HOST=127.0.0.1 +#REFINE_WEBAPP=main\webapp + +# Memory and max form size allocations +#REFINE_MAX_FORM_CONTENT_SIZE=1048576 +REFINE_MEMORY=1400M + +# Set initial java heap space (default: 256M) for better performance with large datasets +REFINE_MIN_MEMORY=1400M + +# Some sample configurations. These have no defaults. +#ANT_HOME=C:\grefine\tools\apache-ant-1.8.1 +#JAVA_HOME=C:\Program Files\Java\jdk1.8.0_151 +#JAVA_OPTIONS=-XX:+UseParallelGC -verbose:gc -Drefine.headless=true +#JAVA_OPTIONS=-Drefine.data_dir=C:\Users\user\AppData\Roaming\OpenRefine +JAVA_HOME={{ jdk_java_home }} +JAVA_OPTIONS="-server -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xms{{ openrefine_java_heap }} -Xmx{{ openrefine_java_heap }} -Drefine.data_dir={{ openrefine_data_dir }}" + +# Uncomment to increase autosave period to 60 mins (default: 5 minutes) for better performance of long-lasting transformations +#REFINE_AUTOSAVE_PERIOD=60