From 2ddfc19a6ebcdca6ab9fb92cc102e9f2f6c88d5a Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 25 Jan 2017 09:52:35 +0100 Subject: [PATCH] library/roles/geonetwork: Role that installs a geonetwork server. --- geonetwork/geonetwork/defaults/main.yml | 14 ++++++ geonetwork/geonetwork/tasks/main.yml | 58 +++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 geonetwork/geonetwork/defaults/main.yml create mode 100644 geonetwork/geonetwork/tasks/main.yml diff --git a/geonetwork/geonetwork/defaults/main.yml b/geonetwork/geonetwork/defaults/main.yml new file mode 100644 index 00000000..b44afb57 --- /dev/null +++ b/geonetwork/geonetwork/defaults/main.yml @@ -0,0 +1,14 @@ +--- +geonetwork_install: False +geonetwork_upgrade: False +geonetwork_major_version: '2.6' +geonetwork_minor_version: 0 +geonetwork_app_name: geonetwork +geonetwork_version: '{{ geonetwork_major_version }}.{{ geonetwork_minor_version }}' +geonetwork_download_url: 'https://downloads.sourceforge.net/project/geonetwork/GeoNetwork_opensource/v{{ geonetwork_version }}/geonetwork.war?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fgeonetwork%2Ffiles%2FGeoNetwork_opensource%2Fv{{ geonetwork_version }}%2F&ts=1485267039&use_mirror=netcologne' + +geonetwork_download_directory: /srv/geonetwork +geonetwork_data_directory: /srv/geonetwork_data + +geonetwork_cubeapp_url: 'https://data.d4science.org/WmEwY1NwZnJ5NUtoUVBUV0w3NlBFdGEvemdvV3lUY1dHbWJQNStIS0N6Yz0' +geonetwork_configxml_url: 'https://data.d4science.org/RGlieWNEaVRDTUdoUVBUV0w3NlBFZ0Uwc2RqRm1zM05HbWJQNStIS0N6Yz0' diff --git a/geonetwork/geonetwork/tasks/main.yml b/geonetwork/geonetwork/tasks/main.yml new file mode 100644 index 00000000..cfe7fe5e --- /dev/null +++ b/geonetwork/geonetwork/tasks/main.yml @@ -0,0 +1,58 @@ +--- +- block: + - name: Create the Geonetwork download directory + file: path={{ geonetwork_download_directory }} state=directory + + - name: Create the Geonetwork data directory + file: path={{ geonetwork_data_directory }} state=directory owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + + - name: Remove the geonetwork webapp if we are upgrading + file: dest={{ item.instance_path }}/webapps/{{ geonetwork_app_name }} state=absent + with_items: '{{ tomcat_m_instances }}' + when: geonetwork_upgrade + + - name: Remove the geonetwork distribution file if we are upgrading + file: dest={{ geonetwork_download_directory }}/geonetwork.war state=absent + when: geonetwork_upgrade + + - name: Create the Geonetwork download directory + file: path={{ geonetwork_download_directory }} state=directory + + - name: Create the Geonetwork webapp directory + file: path={{ item.instance_path }}/webapps/{{ geonetwork_app_name }} state=directory owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + + - name: Download the Geonetwork file distribution + get_url: url='{{ geonetwork_download_url }}' dest={{ geonetwork_download_directory }}/geonetwork.war + + - name: Unpack the Geonetwork war file + unarchive: copy=no src={{ geonetwork_download_directory }}/geonetwork.war dest={{ item.instance_path }}/webapps/{{ geonetwork_app_name }} creates={{ item.instance_path }}/webapps/{{ geonetwork_app_name }}/WEB-INF/lib owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + - name: Install the gcubeapps configuration + get_url: url={{ geonetwork_cubeapp_url }} dest={{ item.instance_path }}/webapps/{{ geonetwork_app_name }}/WEB-INF/gcube-app.xml + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + - name: Configure geonetwork + get_url: url={{ geonetwork_configxml_url }} dest={{ item.instance_path }}/webapps/{{ geonetwork_app_name }}/WEB-INF/config.xml + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + when: geonetwork_install + tags: geonetwork + +- block: + - name: Remove the Geonetwork webapp directory + file: path={{ item.instance_path }}/webapps/{{ geonetwork_app_name }} state=absent + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + - name: Remove the geonetwork distribution file + file: dest={{ geonetwork_download_directory }}/geonetwork.war state=absent + + when: not geonetwork_install + tags: geonetwork +