Skip to content
This repository has been archived by the owner on Oct 10, 2021. It is now read-only.

Commit

Permalink
SQL-based Fedora object persistence (Issue 1244) (#8)
Browse files Browse the repository at this point in the history
* support SQL-based persistence

* support SQL-based object persistence

* use templates instead of default repository.json

* add missing quotes

* use ansible variables in repository.json instead of tomcat JAVA_OPTS

* remove outdated note
  • Loading branch information
seth-shaw-unlv authored and dannylamb committed Aug 29, 2019
1 parent 4a6ff88 commit 10a919e
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 18 deletions.
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,30 @@ Path to put Fedora data directory
fcrepo_data_dir: "{{ fcrepo_home_dir }}/fcrepo4-data"
```

Path to put the Fedora data binaries directory
```
fcrepo_binary_directory: "{{ fcrepo_data_dir}}/binaries"
```

Which Fedora object persistence configuration to use
```
fcrepo_persistence: file-simple
```

If 'file-simple persistence' is used (default), where to keep the modeshape repository file
```
fcrepo_object_directory: "{{ fcrepo_data_dir}}/objects"
```

If either 'jdbc-mysql' or 'jdbc-postgres' are used for object persistence, the database settings
```
fcrepo_db_name: fcrepo
fcrepo_db_user: fcrepo
fcrepo_db_password: fcrepo
fcrepo_db_host: "127.0.0.1"
fcrepo_db_port: "3306"
```

Islandora uses the HeaderProvider to pass the users roles into Fedora. To use this you will need to set the below variable.

Header name to acquire roles from
Expand Down Expand Up @@ -80,21 +104,6 @@ fcrepo_allowed_external_content:
roles:
- { role: islandora.fcrepo }

## Notes

This role only uses the fcrepo_data_dir to create a directory. To tell Fedora
to use this directory you either need to incorporate the value into the
[repository.json template](templates/repository.json) or add it to the Tomcat
Java Opts. For example, if using
[ansible-role-tomcat8](https://github.com/Islandora-Devops/ansible-role-tomcat8)
adding the following to your inventory:
```
fcrepo_data_dir: "/data/fcrepo-data"
tomcat8_java_opts:
- -Dfcrepo.binary.directory={{ fcrepo_data_dir }}
```

## License

MIT
14 changes: 14 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
fcrepo_version: 4.7.2
fcrepo_user: "{{ tomcat8_server_user }}"
fcrepo_data_dir: /var/lib/tomcat8/fcrepo4-data
fcrepo_binary_directory: "{{ fcrepo_data_dir}}/binaries"
fcrepo_war_path: "{{ tomcat8_home }}/webapps/fcrepo.war"
fcrepo_home_dir: /opt/fcrepo
fcrepo_activemq_template: activemq.xml.j2
fcrepo_config_dir: "{{ fcrepo_home_dir }}/configs"

# For file-simple object persistence.
fcrepo_object_directory: "{{ fcrepo_data_dir}}/objects"

# For production use either "jdbc-mysql" or "jdbc-postgresql"
fcrepo_persistence: file-simple

# Used for mysql or postgres object persistence. Please change the password locally!
fcrepo_db_name: fcrepo
fcrepo_db_user: fcrepo
fcrepo_db_password: fcrepo
fcrepo_db_host: "127.0.0.1"
fcrepo_db_port: "3306"

# External content paths can be directories or urls,
# and they MUST end in /
fcrepo_allowed_external_content:
Expand Down
9 changes: 8 additions & 1 deletion tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@
group: "{{ fcrepo_user }}"
with_items:
- claw.cnd
- repository.json
- fcrepo-config.xml
notify: restart tomcat8

- name: Copy templated repository.json
template:
src: "{{ fcrepo_persistence }}-repository.json"
dest: "{{ fcrepo_home_dir }}/configs/repository.json"
owner: "{{ fcrepo_user }}"
group: "{{ fcrepo_user }}"
notify: restart tomcat8

- name: Copy fedora activemq configuration
template:
src: "{{ fcrepo_activemq_template }}"
Expand Down
14 changes: 14 additions & 0 deletions tasks/db-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---

- name: Create Fedora DB (mysql)
mysql_db:
name: "{{ fcrepo_db_name }}"
state: present
register: fcrepo_db_exists

- name: Create Fedora DB User (mysql)
mysql_user:
name: "{{ fcrepo_db_user }}"
password: "{{ fcrepo_db_password }}"
state: present
priv: "{{fcrepo_db_name}}.*:ALL"
13 changes: 13 additions & 0 deletions tasks/db-pgsql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

- name: Create Fedora DB User (pgsql)
postgresql_user:
name: "{{ fcrepo_db_user }}"
password: "{{ fcrepo_db_password }}"

- name: Create Fedora DB (pgsql)
postgresql_db:
name: "{{ fcrepo_db_name }}"
state: present
owner: "{{ fcrepo_db_user }}"
register: fcrepo_db_exists
15 changes: 15 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
- fcrepo
- fcrepo-install

- include: db-mysql.yml
when: fcrepo_persistence == 'jdbc-mysql'
tags:
- fedora
- fedora-install
- fedora-db

- include: db-pgsql.yml
when: fcrepo_persistence == 'jdbc-postgresql'
become: yes
tags:
- fedora
- fedora-install
- fedora-db

- include: config.yml
tags:
- fcrepo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"storage" : {
"persistence": {
"type": "file",
"path" : "${fcrepo.object.directory:target/objects}"
"path" : "{{ fcrepo_object_directory }}"
},
"binaryStorage" : {
"type" : "file",
"directory" : "${fcrepo.binary.directory:target/binaries}",
"directory" : "{{ fcrepo_binary_directory }}",
"minimumBinarySizeInBytes" : 4096
}
},
Expand Down
39 changes: 39 additions & 0 deletions templates/jdbc-mysql-repository.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name" : "repo",
"jndiName" : "",
"workspaces" : {
"predefined" : ["default"],
"default" : "default",
"allowCreation" : true,
"cacheSize" : 10000
},
"storage" : {
"persistence": {
"type" : "db",
"connectionUrl": "jdbc:mysql://{{ fcrepo_db_host }}:{{ fcrepo_db_port }}/{{ fcrepo_db_name }}?createDatabaseIfNotExist=true",
"driver" : "com.mysql.jdbc.Driver",
"username" : "{{ fcrepo_db_user }}",
"password" : "{{ fcrepo_db_password }}"
},
"binaryStorage" : {
"type" : "file",
"directory" : "{{ fcrepo_binary_directory }}",
"minimumBinarySizeInBytes" : 4096
}
},
"security" : {
"anonymous" : {
"roles" : ["readonly","readwrite","admin"],
"useOnFailedLogin" : false
},
"providers" : [
{ "classname" : "org.fcrepo.auth.common.BypassSecurityServletAuthenticationProvider" }
]
},
"garbageCollection" : {
"threadPool" : "modeshape-gc",
"initialTime" : "00:00",
"intervalInHours" : 24
},
"node-types" : ["fedora-node-types.cnd", "file:/opt/fcrepo/configs/claw.cnd"]
}
39 changes: 39 additions & 0 deletions templates/jdbc-postgresql-repository.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name" : "repo",
"jndiName" : "",
"workspaces" : {
"predefined" : ["default"],
"default" : "default",
"allowCreation" : true,
"cacheSize" : 10000
},
"storage" : {
"persistence": {
"type" : "db",
"connectionUrl": "jdbc:postgresql://{{ fcrepo_db_host }}:{{ fcrepo_db_port }}/{{ fcrepo_db_name }}",
"driver" : "org.postgresql.Driver",
"username" : "{{ fcrepo_db_user }}",
"password" : "{{ fcrepo_db_password }}"
},
"binaryStorage" : {
"type" : "file",
"directory" : "{{ fcrepo_binary_directory }}",
"minimumBinarySizeInBytes" : 4096
}
},
"security" : {
"anonymous" : {
"roles" : ["readonly","readwrite","admin"],
"useOnFailedLogin" : false
},
"providers" : [
{ "classname" : "org.fcrepo.auth.common.BypassSecurityServletAuthenticationProvider" }
]
},
"garbageCollection" : {
"threadPool" : "modeshape-gc",
"initialTime" : "00:00",
"intervalInHours" : 24
},
"node-types" : ["fedora-node-types.cnd", "file:/opt/fcrepo/configs/claw.cnd"]
}

0 comments on commit 10a919e

Please sign in to comment.