diff --git a/smartgears/storage_hub/defaults/main.yml b/smartgears/storage_hub/defaults/main.yml new file mode 100644 index 00000000..dba8353c --- /dev/null +++ b/smartgears/storage_hub/defaults/main.yml @@ -0,0 +1,99 @@ +--- +storage_hub_install: False +storage_hub_upgrade: False +storage_hub_version: 1.0.0-4.11.1-167555 +storage_hub_name: storagehub + +storage_hub_group_id: org.gcube.data.access +storage_hub_extension: war +storage_hub_file: '{{ storage_hub_name }}-{{ storage_hub_version }}.{{ storage_hub_extension }}' + + +# storagehub.xml context mapping +storagehub_config_file_path: '{{ smartgears_instance_path }}/{{ jackrabbit_repository_config }}' +storagehub_rep_home_dir: '{{ smartgears_instance_path }}/jackrabbit/workspaces' + + +admin_pwd: "{{ vault_admin_pass }}" + +# Standard jackrabbit configuration +# +jackrabbit_data_dir: /data/jackrabbit + +jackrabbit_config_files: + - bootstrap.properties + - repository.xml + +jackrabbit_rmi_enabled: 'true' +jackrabbit_rmi_host: 'localhost' +jackrabbit_rmi_port: 0 +jackrabbit_repository_config: 'jackrabbit/repository.xml' +jackrabbit_repository_name: 'jackrabbit.repository' +jackrabbit_jndi_enabled: 'true' + +jackrabbit_db_type: 'postgresql' +jackrabbit_db_driver: 'org.postgresql.Driver' +jackrabbit_db_host: 'localhost' + +jackrabbit_virt_fs_db_type: '{{ jackrabbit_db_type }}' +jackrabbit_virt_fs_db_schema: '{{ jackrabbit_db_type }}' +jackrabbit_virt_fs_db_driver: '{{ jackrabbit_db_driver }}' +jackrabbit_virt_fs_db_host: '{{ jackrabbit_db_host }}' +jackrabbit_virt_fs_db_name: 'workspace-db' +jackrabbit_virt_fs_db_user: 'workspace-db-user' +#jackrabbit_virt_fs_db_password: '' +jackrabbit_virt_fs_db_url: 'jdbc:{{ jackrabbit_virt_fs_db_type }}://{{ jackrabbit_virt_fs_db_host }}/{{ jackrabbit_virt_fs_db_name }}' + +# By default the data store uses the same database of the virtual filesystem +jackrabbit_data_store_db_type: '{{ jackrabbit_db_type }}' +jackrabbit_data_store_db_schema: '{{ jackrabbit_db_type }}' +jackrabbit_data_store_db_driver: '{{ jackrabbit_db_driver }}' +jackrabbit_data_store_db_host: '{{ jackrabbit_db_host }}' +jackrabbit_data_store_db_name: '{{ jackrabbit_virt_fs_db_name }}' +jackrabbit_data_store_db_user: '{{ jackrabbit_virt_fs_db_user }}' +jackrabbit_data_store_db_password: '{{ jackrabbit_virt_fs_db_password }}' +jackrabbit_data_store_db_url: 'jdbc:{{ jackrabbit_data_store_db_type }}://{{ jackrabbit_data_store_db_host }}/{{ jackrabbit_data_store_db_name }}' +jackrabbit_data_store_db_tableprefix: 'datastore_' + +jackrabbit_security_adminid: 'jr_admin' +#jackrabbit_security_admin_pwd: '' + +jackrabbit_ws_default_workspace: 'default' + +jackrabbit_ws_persistence_manager: 'org.apache.jackrabbit.core.persistence.pool.PostgreSQLPersistenceManager' +jackrabbit_ws_persistence_manager_db_type: '{{ jackrabbit_db_type }}' +jackrabbit_ws_persistence_manager_db_schema: '{{ jackrabbit_db_type }}' +jackrabbit_ws_persistence_manager_db_driver: '{{ jackrabbit_db_driver }}' +jackrabbit_ws_persistence_manager_db_host: '{{ jackrabbit_db_host }}' +jackrabbit_ws_persistence_manager_db_name: '{{ jackrabbit_virt_fs_db_name }}' +jackrabbit_ws_persistence_manager_db_user: '{{ jackrabbit_virt_fs_db_user }}' +jackrabbit_ws_persistence_manager_db_password: '{{ jackrabbit_virt_fs_db_password }}' +jackrabbit_ws_persistence_manager_db_url: 'jdbc:{{ jackrabbit_ws_persistence_manager_db_type }}://{{ jackrabbit_ws_persistence_manager_db_host }}/{{ jackrabbit_ws_persistence_manager_db_name }}' +jackrabbit_ws_persistence_manager_db_tableprefix: 'pm_${wsp.name}_' + +jackrabbit_ver_persistence_manager: 'org.apache.jackrabbit.core.persistence.pool.PostgreSQLPersistenceManager' +jackrabbit_ver_persistence_manager_db_type: '{{ jackrabbit_db_type }}' +jackrabbit_ver_persistence_manager_db_schema: '{{ jackrabbit_db_type }}' +jackrabbit_ver_persistence_manager_db_driver: '{{ jackrabbit_db_driver }}' +jackrabbit_ver_persistence_manager_db_host: '{{ jackrabbit_db_host }}' +jackrabbit_ver_persistence_manager_db_name: '{{ jackrabbit_virt_fs_db_name }}' +jackrabbit_ver_persistence_manager_db_user: '{{ jackrabbit_virt_fs_db_user }}' +jackrabbit_ver_persistence_manager_db_password: '{{ jackrabbit_virt_fs_db_password }}' +jackrabbit_ver_persistence_manager_db_url: 'jdbc:{{ jackrabbit_ver_persistence_manager_db_type }}://{{ jackrabbit_ver_persistence_manager_db_host }}/{{ jackrabbit_ver_persistence_manager_db_name }}' +jackrabbit_ver_persistence_manager_db_tableprefix: 'pm_version_' + +# Cluster configuration. Same db host by default, different DB +jackrabbit_cluster_db_host: '{{ jackrabbit_db_host }}' +jackrabbit_cluster_db_type: '{{ jackrabbit_db_type }}' +jackrabbit_cluster_db_schema: '{{ jackrabbit_db_type }}' +jackrabbit_cluster_db_driver: '{{ jackrabbit_db_driver }}' +jackrabbit_cluster_db_name: 'ws-db-cluster-journal' +jackrabbit_cluster_db_user: 'ws-db-journal-user' +# jackrabbit_cluster_db_password: '' +jackrabbit_cluster_db_url: 'jdbc:{{ jackrabbit_cluster_db_type }}://{{ jackrabbit_cluster_db_host }}/{{ jackrabbit_cluster_db_name }}' +jackrabbit_cluster_db_tableprefix: 'journal_' +jackrabbit_cluster_node_id: '{{ ansible_fqdn }}' +# Set it to true if we want to clean the journal daily +jackrabbit_cluster_janitor_enabled: 'false' + + diff --git a/smartgears/storage_hub/tasks/main.yml b/smartgears/storage_hub/tasks/main.yml new file mode 100644 index 00000000..a4f6304f --- /dev/null +++ b/smartgears/storage_hub/tasks/main.yml @@ -0,0 +1,70 @@ +--- +- block: + - name: Remove the installed home library/ storagehub when we do not want it installed + file: dest={{ item }} state=absent + with_items: + - '{{ smartgears_instance_path }}/webapps/{{ home_library_name }}' + - '{{ smartgears_instance_path }}/webapps/{{ home_library_name }}.war' + - '{{ smartgears_instance_path }}/webapps/{{ storage_hub_name }}' + - '{{ smartgears_instance_path }}/webapps/{{ storage_hub_name }}.war' + notify: Restart smartgears + + become: True + become_user: '{{ smartgears_user }}' + when: not storage_hub_install + tags: [ 'smartgears', 'storage_hub', 'tomcat' ] + +- block: + - maven_artifact: artifact_id={{ storage_hub_name }} version={{ storage_hub_version | default(omit) }} group_id={{ storage_hub_group_id }} extension={{ storage_hub_extension | default('war') }} repository_url={{ smartgears_global_base_url }} dest={{ smartgears_downloads_dir }}/{{ storage_hub_file }} + register: storage_hub_download + + - name: Remove the installed storage hub before upgrading + file: dest={{ smartgears_instance_path }}/webapps/{{ storage_hub_name }} state=absent + when: ( storage_hub_download | changed ) + notify: Restart smartgears + + - name: Get the StorageHub war + maven_artifact: artifact_id={{ storage_hub_name }} version={{ storage_hub_ver | default('latest') }} group_id={{ storage_hub_group_id }} extension={{ storage_hub_extension }} repository_url={{ smartgears_global_base_url }} dest={{ smartgears_downloads_dir }}/{{ storage_hub_file }} + register: storage_hub_download + + + - name: Create the storage_hub webapp directory + file: dest={{ smartgears_instance_path }}/webapps/{{ storage_hub_name }} state=directory + when: storage_hub_download + + - name: Unarchive the storage_hub war file + unarchive: copy=no src={{ smartgears_downloads_dir }}/{{ storage_hub_file }} dest={{ smartgears_instance_path }}/webapps/{{ storage_hub_name }} + args: + creates: '{{ smartgears_instance_path }}/webapps/{{ storage_hub_name }}/WEB-INF/web.xml' + notify: Restart smartgears + + - name: Install the storage_hub web.xml template + template: src=storage-hub-web.xml.j2 dest={{ smartgears_instance_path }}/webapps/{{ storage_hub_name }}/WEB-INF/web.xml mode=0440 + notify: Restart smartgears + + - name: Create the JackRabbit persistence directory + become_user: root + file: dest={{ jackrabbit_data_dir }} state=directory owner={{ smartgears_user }} group={{ smartgears_user }} + + - name: Verify if the JackRabbit persistence directory is in the place where the service expects it + stat: path={{ smartgears_instance_path }}/jackrabbit + register: jackrabbit_data_path + + - name: Link the data dir to the place where jackrabbit expects it + file: src={{ jackrabbit_data_dir }} dest={{ smartgears_instance_path }}/jackrabbit state=link + when: not jackrabbit_data_path.stat.exists + + - name: Install the repository configuration files + template: src={{ item }}.j2 dest={{ jackrabbit_data_dir }}/{{ item }} + with_items: '{{ jackrabbit_config_files }}' + notify: Restart smartgears + +# - name: Install the additional service context default file +# template: src=storagehub.xml.j2 dest={{ smartgears_instance_path }}/conf/Catalina/localhost/storagehub.xml mode=0664 +# notify: Restart smartgears + + become: True + become_user: '{{ smartgears_user }}' + when: storage_hub_install + tags: [ 'smartgears', 'storage_hub', 'tomcat' ] + diff --git a/smartgears/storage_hub/templates/bootstrap.properties.j2 b/smartgears/storage_hub/templates/bootstrap.properties.j2 new file mode 100644 index 00000000..6dbe7b0a --- /dev/null +++ b/smartgears/storage_hub/templates/bootstrap.properties.j2 @@ -0,0 +1,11 @@ +#bootstrap properties for the repository startup servlet. +#Fri Jul 21 05:19:29 CEST 2017 +java.naming.factory.initial=org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory +repository.home=jackrabbit +rmi.enabled={{ jackrabbit_rmi_enabled }} +repository.config={{ jackrabbit_repository_config }} +repository.name={{ jackrabbit_repository_name }} +rmi.host={{ jackrabbit_rmi_host }} +java.naming.provider.url=http\://www.apache.org/jackrabbit +jndi.enabled={{ jackrabbit_jndi_enabled }} +rmi.port={{ jackrabbit_rmi_port }} diff --git a/smartgears/storage_hub/templates/repository.xml.j2 b/smartgears/storage_hub/templates/repository.xml.j2 new file mode 100644 index 00000000..3621370e --- /dev/null +++ b/smartgears/storage_hub/templates/repository.xml.j2 @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/smartgears/storage_hub/templates/storage-hub-web.xml.j2 b/smartgears/storage_hub/templates/storage-hub-web.xml.j2 new file mode 100644 index 00000000..447f6959 --- /dev/null +++ b/smartgears/storage_hub/templates/storage-hub-web.xml.j2 @@ -0,0 +1,19 @@ + + + admin-username + {{ jackrabbit_security_adminid }} + + + admin-pwd + {{ admin_pwd }} + + + + org.gcube.data.access.storagehub.StorageHub + + + + org.gcube.data.access.storagehub.StorageHub + /workspace/* + + diff --git a/smartgears/storage_hub/templates/storagehub.xml.j2 b/smartgears/storage_hub/templates/storagehub.xml.j2 new file mode 100644 index 00000000..416c9240 --- /dev/null +++ b/smartgears/storage_hub/templates/storagehub.xml.j2 @@ -0,0 +1,11 @@ + + + +