Skip to content

Commit

Permalink
Add Fuseki installation and configurations for locally-hosted example…
Browse files Browse the repository at this point in the history
… data
  • Loading branch information
mikipernu authored and osma committed Apr 23, 2019
1 parent 59d27df commit b8f3929
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
7 changes: 5 additions & 2 deletions ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions ansible/roles/base/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

- name: Add 'openjdk' repository
apt_repository:
repo: ppa:openjdk-r/ppa
state: present
5 changes: 5 additions & 0 deletions ansible/roles/fuseki/files/fuseki
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export FUSEKI_HOME=/opt/fuseki
export FUSEKI_BASE=/etc/fuseki

FUSEKI_USER=fuseki
JAVA_OPTIONS="-Xmx2048M"
58 changes: 58 additions & 0 deletions ansible/roles/fuseki/files/skosmos.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@prefix : <http://base/#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix text: <http://jena.apache.org/text#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

: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 <file:/etc/fuseki/databases/skosmos/text> ;
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 ]
]
) .
145 changes: 145 additions & 0 deletions ansible/roles/fuseki/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions ansible/roles/openjdk/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: Update apt-cache and then install openjdk-8-jre
apt:
name: openjdk-8-jre
update_cache: yes
state: present
8 changes: 4 additions & 4 deletions ansible/roles/skosmos/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b8f3929

Please sign in to comment.