From b8f3929d3e9700661194953dba3204526d8bce02 Mon Sep 17 00:00:00 2001 From: Miki Pernu Date: Thu, 13 Sep 2018 11:38:06 +0300 Subject: [PATCH] Add Fuseki installation and configurations for locally-hosted example data --- Vagrantfile | 5 +- ansible/playbook.yml | 7 +- ansible/roles/base/tasks/main.yml | 5 + ansible/roles/fuseki/files/fuseki | 5 + ansible/roles/fuseki/files/skosmos.ttl | 58 ++++++++++ ansible/roles/fuseki/tasks/main.yml | 145 +++++++++++++++++++++++++ ansible/roles/openjdk/tasks/main.yml | 5 + ansible/roles/skosmos/tasks/main.yml | 8 +- 8 files changed, 230 insertions(+), 8 deletions(-) create mode 100644 ansible/roles/base/tasks/main.yml create mode 100644 ansible/roles/fuseki/files/fuseki create mode 100644 ansible/roles/fuseki/files/skosmos.ttl create mode 100644 ansible/roles/fuseki/tasks/main.yml create mode 100644 ansible/roles/openjdk/tasks/main.yml diff --git a/Vagrantfile b/Vagrantfile index d89b0a565..734b9da6a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,8 +4,9 @@ Vagrant.configure(2) do |config| config.vm.box = "ubuntu/xenial64" - config.vm.network "forwarded_port", guest: 80, host: 8040 - config.vm.post_up_message = "Skosmos up and running at localhost:8040/Skosmos" + config.vm.network "forwarded_port", guest: 80, host: 8010 + config.vm.network "forwarded_port", guest: 3030, host: 3030 + config.vm.post_up_message = "Skosmos up and running at localhost:8010/Skosmos, Fuseki at localhost:3030" config.vm.synced_folder "", "/var/www/html/Skosmos" diff --git a/ansible/playbook.yml b/ansible/playbook.yml index 4f6c3554d..84a80b501 100644 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -3,8 +3,11 @@ become: True gather_facts: False roles: + - base + - openjdk + - fuseki - skosmos pre_tasks: - - name: Install Zip and Unzip for Ansible - raw: sudo apt-get install zip unzip + - name: Install Unzip for Ansible + raw: sudo apt-get install unzip - setup: # aka gather_facts diff --git a/ansible/roles/base/tasks/main.yml b/ansible/roles/base/tasks/main.yml new file mode 100644 index 000000000..d84684847 --- /dev/null +++ b/ansible/roles/base/tasks/main.yml @@ -0,0 +1,5 @@ + +- name: Add 'openjdk' repository + apt_repository: + repo: ppa:openjdk-r/ppa + state: present diff --git a/ansible/roles/fuseki/files/fuseki b/ansible/roles/fuseki/files/fuseki new file mode 100644 index 000000000..258542c73 --- /dev/null +++ b/ansible/roles/fuseki/files/fuseki @@ -0,0 +1,5 @@ +export FUSEKI_HOME=/opt/fuseki +export FUSEKI_BASE=/etc/fuseki + +FUSEKI_USER=fuseki +JAVA_OPTIONS="-Xmx2048M" \ No newline at end of file diff --git a/ansible/roles/fuseki/files/skosmos.ttl b/ansible/roles/fuseki/files/skosmos.ttl new file mode 100644 index 000000000..a625cf927 --- /dev/null +++ b/ansible/roles/fuseki/files/skosmos.ttl @@ -0,0 +1,58 @@ +@prefix : . +@prefix tdb: . +@prefix rdf: . +@prefix ja: . +@prefix rdfs: . +@prefix fuseki: . +@prefix text: . +@prefix skos: . + +:service_tdb_all a fuseki:Service ; + rdfs:label "TDB+text skosmos" ; + fuseki:dataset :text_dataset ; + fuseki:name "skosmos" ; + fuseki:serviceQuery "query" , "sparql" ; + fuseki:serviceReadGraphStore "get" ; + fuseki:serviceReadWriteGraphStore + "data" ; + fuseki:serviceUpdate "update" ; + fuseki:serviceUpload "upload" . + +:text_dataset a text:TextDataset ; + text:dataset :tdb_dataset_readwrite ; +# tdb:unionDefaultGraph true ; + text:index :index_lucene . + +:tdb_dataset_readwrite + a tdb:DatasetTDB ; + tdb:location "/etc/fuseki/databases/skosmos" . + +:index_lucene a text:TextIndexLucene ; + text:directory ; + text:entityMap :entity_map ; + text:storeValues true . + +# Text index configuration for Skosmos 1.4 and above (requires Fuseki 1.3.0+ or 2.3.0+) +:entity_map a text:EntityMap ; + text:entityField "uri" ; + text:graphField "graph" ; + text:defaultField "pref" ; + text:uidField "uid" ; + text:langField "lang" ; + text:map ( + # skos:prefLabel + [ text:field "pref" ; + text:predicate skos:prefLabel ; + text:analyzer [ a text:LowerCaseKeywordAnalyzer ] + ] + # skos:altLabel + [ text:field "alt" ; + text:predicate skos:altLabel ; + text:analyzer [ a text:LowerCaseKeywordAnalyzer ] + ] + # skos:hiddenLabel + [ text:field "hidden" ; + text:predicate skos:hiddenLabel ; + text:analyzer [ a text:LowerCaseKeywordAnalyzer ] + ] + ) . diff --git a/ansible/roles/fuseki/tasks/main.yml b/ansible/roles/fuseki/tasks/main.yml new file mode 100644 index 000000000..f5b15a938 --- /dev/null +++ b/ansible/roles/fuseki/tasks/main.yml @@ -0,0 +1,145 @@ + +- name: Download Fuseki tarball + get_url: + url: https://archive.apache.org/dist/jena/binaries/apache-jena-fuseki-3.8.0.tar.gz + dest: /home/vagrant/ + mode: 755 + +- name: Extract Fuseki to opt/ + command: chdir=/opt /bin/tar xzf /home/vagrant/apache-jena-fuseki-3.8.0.tar.gz + args: + warn: false + +- name: Create a symbolic link to /opt/fuseki + file: + src: /opt/apache-jena-fuseki-3.8.0 + dest: /opt/fuseki + state: link + +- name: Add a new user fuseki + user: + name: fuseki + home: /opt/fuseki + system: yes + create_home: no + +- name: Create directories to /var/lib + file: + path: "/var/lib/fuseki/{{ item }}" + state: directory + owner: fuseki + group: fuseki + mode: 0775 + with_items: + - backups + - databases + - system + - system_files + +- name: Create directories + file: + path: "{{ item }}" + state: directory + owner: fuseki + group: fuseki + mode: 0775 + with_items: + - /var/log/fuseki + - /etc/fuseki + +- name: Link fuseki home + file: + src: "/var/lib/fuseki/{{ item }}" + dest: /etc/fuseki/{{ item }} + state: link + with_items: + - backups + - databases + - system + - system_files + +- name: Link logs to /etc/fuseki/logs + file: + src: /var/log/fuseki + dest: /etc/fuseki/logs + state: link + +- name: Copy Fuseki config + copy: + src: files/fuseki + dest: /etc/default/ + +- name: Setup autostart + command: chdir=/etc/init.d ln -s /opt/fuseki/fuseki . + args: + warn: false + ignore_errors: yes + +- name: Update services + command: update-rc.d fuseki defaults + +- name: Start service Fuseki + service: + name: fuseki + state: started + +- name: Create Skosmos database + uri: + url: http://localhost:3030/$/datasets/ + method: POST + body: dbName=skosmos&dbType=tdb + body_format: raw + +- name: Shut down service Fuseki for configuration + service: + name: fuseki + state: stopped + +- name: Create configuration directory for Skosmos datasets + file: + path: etc/fuseki/configuration + state: directory + +- name: Create text index for Skosmos datasets + copy: + src: files/skosmos.ttl + dest: etc/fuseki/configuration/skosmos.ttl + +- name: Allow management operations for non-localhost access + lineinfile: + path: /etc/fuseki/shiro.ini + line: "/$/** = anon" + +- name: Start service Fuseki + service: + name: fuseki + state: started + +- name: Install Ruby + apt: + name: ruby + update_cache: yes + state: present + +- name: Download example vocabulary data (STW Thesaurus) + get_url: + url: http://zbw.eu/stw/version/latest/download/stw.ttl.zip + dest: /home/vagrant/ + mode: 755 + +- name: Unzip STW Thesaurus data file + command: unzip /home/vagrant/stw.ttl.zip -d /home/vagrant/ + args: + warn: false + +- name: Download example vocabulary data (UNESCO Thesaurus) + get_url: + url: http://skos.um.es/unescothes/unescothes.ttl + dest: /home/vagrant/ + mode: 755 + +- name: Load example vocabulary data (STW Thesaurus) + command: /opt/fuseki/bin/s-put http://localhost:3030/skosmos/data http://zbw.eu/stw/ /home/vagrant/stw.ttl + +- name: Load example vocabulary data (UNESCO Thesaurus) + command: /opt/fuseki/bin/s-put http://localhost:3030/skosmos/data http://skos.um.es/unescothes/ /home/vagrant/unescothes.ttl diff --git a/ansible/roles/openjdk/tasks/main.yml b/ansible/roles/openjdk/tasks/main.yml new file mode 100644 index 000000000..8e6c05481 --- /dev/null +++ b/ansible/roles/openjdk/tasks/main.yml @@ -0,0 +1,5 @@ +- name: Update apt-cache and then install openjdk-8-jre + apt: + name: openjdk-8-jre + update_cache: yes + state: present diff --git a/ansible/roles/skosmos/tasks/main.yml b/ansible/roles/skosmos/tasks/main.yml index 39c078d9c..0d900dca2 100644 --- a/ansible/roles/skosmos/tasks/main.yml +++ b/ansible/roles/skosmos/tasks/main.yml @@ -52,13 +52,13 @@ - name: Copy global and vocabulary-specific configurations copy: - src: /var/www/html/Skosmos/config.ttl.dist + src: files/config.ttl dest: /var/www/html/Skosmos/config.ttl - remote_src : yes - name: Generate locales, if necessary shell: "locale-gen {{ item }}" with_items: - en_GB.utf8 - - fi_FI.utf8 - - sv_SE.utf8 + - de_DE.utf8 + # - fi_FI.utf8 + # - sv_SE.utf8