From e2493de2b805d575ea6ca6461b87e13ffb171d78 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 11 Aug 2020 16:16:52 +0200 Subject: [PATCH] Import the old role. --- README.md | 42 +-- defaults/main.yml | 16 +- handlers/main.yml | 2 - meta/main.yml | 66 ++-- tasks/main.yml | 68 ++++- templates/catalog.xml.j2 | 49 +++ templates/log4j2.xml.j2 | 219 ++++++++++++++ templates/threddsConfig.xml.j2 | 274 +++++++++++++++++ templates/web.xml.j2 | 532 +++++++++++++++++++++++++++++++++ templates/wmsConfig.xml.j2 | 105 +++++++ vars/main.yml | 9 +- 11 files changed, 1312 insertions(+), 70 deletions(-) delete mode 100644 handlers/main.yml create mode 100644 templates/catalog.xml.j2 create mode 100755 templates/log4j2.xml.j2 create mode 100644 templates/threddsConfig.xml.j2 create mode 100644 templates/web.xml.j2 create mode 100644 templates/wmsConfig.xml.j2 diff --git a/README.md b/README.md index 3637db8..bde50a3 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,37 @@ Role Name ========= -A brief description of the role goes here. - -Requirements ------------- - -Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. +A role that installs the THREDDS Data Server, Role Variables -------------- -A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. +The most important variables are listed below: + +``` yaml +thredds_install: True +thredds_upgrade: False +thredds_version: 4.6.15 +thredds_data_content_dir: /data/thredds +thredds_server_name: 'Thredds instance' +thredds_logo_url: '/thredds/threddsIcon.gif' +thredds_logo_alt_text: '{{ thredds_server_name }}' +thredds_organization: 'ORG' +thredds_email: '' +thredds_host_institution_name: 'ORG' +thredds_host_institution_web: '' +thredds_force_ssl_for_user_data: False +thredds_abstract: 'Scientific Data' +thredds_contact_name: 'Support' +thredds_google_analytics_key: '' +``` Dependencies ------------ -A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. - -Example Playbook ----------------- - -Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: - - - hosts: servers - roles: - - { role: username.rolename, x: 42 } +* openjdk +* tomcat +* tomcat-multiple-instances License ------- @@ -35,4 +41,4 @@ EUPL-1.2 Author Information ------------------ -An optional section for the role authors to include contact information, or a website (HTML is not allowed). +Andrea Dell'Amico, diff --git a/defaults/main.yml b/defaults/main.yml index 95d3c70..27b4abc 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,16 @@ --- -# defaults file for ansible-role-template \ No newline at end of file +thredds_install: True +thredds_upgrade: False +thredds_version: 4.6.15 +thredds_data_content_dir: /data/thredds +thredds_server_name: 'Thredds instance' +thredds_logo_url: '/thredds/threddsIcon.gif' +thredds_logo_alt_text: '{{ thredds_server_name }}' +thredds_organization: 'ORG' +thredds_email: '' +thredds_host_institution_name: 'ORG' +thredds_host_institution_web: '' +thredds_force_ssl_for_user_data: False +thredds_abstract: 'Scientific Data' +thredds_contact_name: 'Support' +thredds_google_analytics_key: '' diff --git a/handlers/main.yml b/handlers/main.yml deleted file mode 100644 index 27474e0..0000000 --- a/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# handlers file for ansible-role-template \ No newline at end of file diff --git a/meta/main.yml b/meta/main.yml index 1126a5e..b0a1493 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,61 +1,33 @@ galaxy_info: - author: your name - description: your description + author: Andrea Dell'Amico + description: Systems Architect company: ISTI-CNR - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning - # Some suggested licenses: - # - BSD (default) - # - MIT - # - GPLv2 - # - GPLv3 - # - Apache - # - CC-BY - license: EUPL-1.2 + license: EUPL 1.2+ min_ansible_version: 2.8 - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - # Optionally specify the branch Galaxy will use when accessing the GitHub - # repo for this role. During role install, if no tags are available, - # Galaxy will use this branch. During import Galaxy will access files on - # this branch. If Travis integration is configured, only notifications for this - # branch will be accepted. Otherwise, in all cases, the repo's default branch - # (usually master) will be used. - #github_branch: - - # - # Provide a list of supported platforms, and for each platform a list of versions. - # If you don't wish to enumerate all versions for a particular platform, use 'all'. # To view available platforms and versions (or releases), visit: # https://galaxy.ansible.com/api/v1/platforms/ # - # platforms: - # - name: Fedora - # versions: - # - all - # - 25 - # - name: SomePlatform - # versions: - # - all - # - 1.0 - # - 7 - # - 99.99 + platforms: + - name: Ubuntu + versions: + - bionic + - name: EL + versions: + - 7 + - 8 - galaxy_tags: [] - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. + galaxy_tags: + - thredds + - datasets -dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. +dependencies: + - src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-tomcat-multiple-instances.git + version: master + name: tomcat-multiple-instances + state: latest diff --git a/tasks/main.yml b/tasks/main.yml index 53c6cae..5c24f43 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,68 @@ --- -# tasks file for ansible-role-template \ No newline at end of file +- block: + - name: Remove the Thredds webapp directory + file: path={{ item.instance_path }}/webapps/{{ thredds_app_name | lower }} state=absent + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + when: not thredds_install or thredds_upgrade + tags: [ 'thredds', 'tomcat' ] + +- block: + - name: Create the Thredds webapp directory + file: path={{ item.instance_path }}/webapps/{{ thredds_app_name | lower }} state=directory owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + + - name: Create the Thredds data directory + file: path={{ thredds_data_content_dir }} state=directory owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + + - name: Check if the configuration files were already initialized with our versions + stat: path={{ thredds_data_content_dir }}/thredds/.conf_initialized + register: thredds_skip_conf + tags: [ 'thredds', 'tomcat', 'thredds_conf' ] + + - name: Install the Thredds data configuration files -only at initialization- + template: src={{ item[1] }}.j2 dest={{ thredds_data_content_dir }}/thredds/{{ item[1] }} owner={{ item.0.user }} group={{ item.0.user }} mode=644 + with_nested: + - '{{ tomcat_m_instances }}' + - ['catalog.xml', 'wmsConfig.xml' ] + notify: tomcat instances restart + when: not thredds_skip_conf.stat.exists + tags: [ 'thredds', 'tomcat', 'thredds_conf' ] + + - name: Install-update the Thredds data configuration files + template: src={{ item[1] }}.j2 dest={{ thredds_data_content_dir }}/thredds/{{ item[1] }} owner={{ item.0.user }} group={{ item.0.user }} mode=644 + with_nested: + - '{{ tomcat_m_instances }}' + - [ 'threddsConfig.xml'] + notify: tomcat instances restart + tags: [ 'thredds', 'tomcat', 'thredds_conf' ] + + - name: Create the file that states that the thredds instance has been configured + copy: content="initialized by ansible" dest={{ thredds_data_content_dir }}/thredds/.conf_initialized mode=0400 + register: thredds_skip_conf + tags: [ 'thredds', 'tomcat', 'thredds_conf' ] + + - name: Get the thredds war file + maven_artifact: artifact_id={{ thredds_name }} version={{ thredds_version | default(omit) }} group_id={{ thredds_group_id }} extension={{ thredds_extension | default('war') }} repository_url={{ thredds_repository_url }} dest={{ thredds_download_directory }}/{{ thredds_file }} + + - name: Unarchive the thredds war + unarchive: copy=no src={{ thredds_download_directory }}/{{ thredds_file }} dest={{ item.instance_path }}/webapps/{{ thredds_app_name | lower }} creates={{ item.instance_path }}/webapps/{{ thredds_app_name | lower }}/WEB-INF/lib owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + - name: Install the Thredds webapp configuration files + template: src=web.xml.j2 dest={{ item.instance_path }}/webapps/{{ thredds_app_name | lower }}/WEB-INF/web.xml owner={{ item.user }} group={{ item.user }} mode=644 + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + tags: [ 'thredds', 'tomcat', 'thredds_conf', 'thredds_webxml' ] + + - name: Install the Thredds log4j configuration file + template: src=log4j2.xml.j2 dest={{ item.instance_path }}/webapps/{{ thredds_app_name | lower }}/WEB-INF/classes/log4j2.xml owner=root group=root mode=0444 + with_items: '{{ tomcat_m_instances }}' + tags: [ 'thredds', 'tomcat', 'thredds_conf', 'thredds_log4j' ] + + when: thredds_install + tags: [ 'thredds', 'tomcat' ] + diff --git a/templates/catalog.xml.j2 b/templates/catalog.xml.j2 new file mode 100644 index 0000000..9f21906 --- /dev/null +++ b/templates/catalog.xml.j2 @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + all + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/log4j2.xml.j2 b/templates/log4j2.xml.j2 new file mode 100755 index 0000000..aaddff1 --- /dev/null +++ b/templates/log4j2.xml.j2 @@ -0,0 +1,219 @@ + + + + ../content + {{ item.instance_path }}/logs/thredds + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/threddsConfig.xml.j2 b/templates/threddsConfig.xml.j2 new file mode 100644 index 0000000..79e1474 --- /dev/null +++ b/templates/threddsConfig.xml.j2 @@ -0,0 +1,274 @@ + + + + + + + {{ thredds_server_name }} + {{ thredds_logo_url }} + {{ thredds_logo_alt_text }} + + {{ thredds_abstract }} + meteorology, atmosphere, climate, ocean, earth science + + + {{ thredds_contact_name}} + {{ thredds_organization }} + {{ thredds_email }} + + + + {{ thredds_host_institution_name }} + {{ thredds_host_institution_web }} + + + + + + + + + tds.css + tdsCat.css + tdsDap.css + + + {{ thredds_google_analytics_key }} + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + true + false + 15 min + 30 min + + + + + + true + false + 2048 + 2048 + {% if thredds_palettes_customisation %} + customPalettes + {% endif %} + + + + + + true + true + true + + + + + + + + + + + + + + + + + + diff --git a/templates/web.xml.j2 b/templates/web.xml.j2 new file mode 100644 index 0000000..b1f386c --- /dev/null +++ b/templates/web.xml.j2 @@ -0,0 +1,532 @@ + + + THREDDS Data Server + THREDDS Data Server + + + + + ContextPath + thredds + + + + + RequestBracketingLogMessageFilter + thredds.server.RequestBracketingLogMessageFilter + + + + RequestPathFilter + thredds.servlet.filter.RequestPathFilter + + + + RequestQueryFilter + thredds.servlet.filter.RequestQueryFilter + + + + RequestQueryFilterAllowAngleBrackets + thredds.servlet.filter.RequestQueryFilter + + allowAngleBrackets + true + + + + + + + CookieFilter + thredds.servlet.filter.CookieFilter + + + + RequestCORSFilter + + org.springframework.web.filter.DelegatingFilterProxy + + targetBeanName + corsFilter + + + + + RequestBracketingLogMessageFilter + + /* + + + + + RequestPathFilter + /* + + + + + RequestQueryFilter + root + + + + + + + + RequestQueryFilter + RestrictedDataset + + + RequestCORSFilter + /* + + + + RequestQueryFilter + wms + + + + + + + RequestQueryFilterAllowAngleBrackets + Opendap + + + + + + + + CookieFilter + Opendap + + + + + + + + contextConfigLocation + /WEB-INF/applicationContext-tdsConfig.xml + + + + org.springframework.web.context.ContextLoaderListener + + + + thredds.server.opendap.OpendapSessionAttributeListener + + + + + + + + + + + + + + root + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + /WEB-INF/servlet-context.xml + + 1 + + + + + + + + + OPeNDAP Server + Opendap + thredds.server.opendap.OpendapServlet + 2 + + + + + + + + + + + + + wms + org.springframework.web.servlet.DispatcherServlet + 4 + + + + + RestrictedDataset + thredds.servlet.restrict.RestrictedDatasetServlet + + + Authorizer + thredds.servlet.restrict.TomcatAuthorizer + + + + useSSL + false + + + + portSSL + 8443 + + + 2 + + + + + + + + + + + + + + + + + root + / + + + root + *.css + + + root + *.gif + + + + + + + + + Opendap + /dodsC/* + + + + + + RestrictedDataset + /restrictedAccess/* + + + + + + wms + /wms/* + + + + + + + + + / + + + + 404 + /WEB-INF/jsp/errorpages/404.jsp + + + 500 + /WEB-INF/jsp/errorpages/500.jsp + + + + + + + + + sensitive read access + /admin/* + + + tdsConfig + +{% if thredds_force_ssl_for_user_data %} + + CONFIDENTIAL + +{% endif %} + + + + + + allow feature collection rescan to be triggered externally + /admin/collection/trigger + /admin/trigger + + + tdsTrigger + +{% if thredds_force_ssl_for_user_data %} + + CONFIDENTIAL + +{% endif %} + + + + + + + + sensitive read access + /admin/log/* + + + tdsMonitor + +{% if thredds_force_ssl_for_user_data %} + + CONFIDENTIAL + +{% endif %} + + + + + + restricted access datasets + /restrictedAccess/* + + + restrictedDatasetUser + +{% if thredds_force_ssl_for_user_data %} + + CONFIDENTIAL + +{% endif %} + + + + + BASIC + THREDDS Data Server + + + + + The configuration role allows users to configure the THREDDS server. + tdsConfig + + + + User who can download tds logs for monitoring purposes. + tdsMonitor + + + + User is allowed to trigger featureCollection rereads + tdsTrigger + + + + User who can access restricted datasets. + restrictedDatasetUser + + + diff --git a/templates/wmsConfig.xml.j2 b/templates/wmsConfig.xml.j2 new file mode 100644 index 0000000..5b94dfb --- /dev/null +++ b/templates/wmsConfig.xml.j2 @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]> + + + + + + + + true + -50 50 + rainbow + 20 + false + + + + + + + 268 308 + + + 268 308 + + + true + + + + + + + + + + + + + false + occam + + + + + + 10 20 + + + + + {% if thredds_palettes_customisation %} + + + 0 1 + aquamaps + 5 + + + {% endif %} + + + + diff --git a/vars/main.yml b/vars/main.yml index 3808477..fcc4ad1 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,9 @@ --- -# vars file for ansible-role-template \ No newline at end of file +thredds_name: tds +thredds_app_name: Thredds +thredds_group_id: edu.ucar +thredds_extension: war +thredds_file: '{{ thredds_name }}-{{ thredds_version }}.{{ thredds_extension }}' +thredds_repository_url: 'https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases' +thredds_download_directory: /srv +thredds_public_netcdf_dir: '{{ thredds_data_content_dir }}/thredds/public/netcdf/'