From cf93b2011f620d28b9073c2207407f977777ddcd Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 4 Dec 2018 16:08:32 +0100 Subject: [PATCH] Role that installs and configure the java reverse proxy servlet. --- .../java_reverse_proxy/defaults/main.yml | 12 +++++ smartgears/java_reverse_proxy/tasks/main.yml | 49 +++++++++++++++++ .../java_reverse_proxy/templates/web.xml | 52 +++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 smartgears/java_reverse_proxy/defaults/main.yml create mode 100644 smartgears/java_reverse_proxy/tasks/main.yml create mode 100644 smartgears/java_reverse_proxy/templates/web.xml diff --git a/smartgears/java_reverse_proxy/defaults/main.yml b/smartgears/java_reverse_proxy/defaults/main.yml new file mode 100644 index 0000000..881a666 --- /dev/null +++ b/smartgears/java_reverse_proxy/defaults/main.yml @@ -0,0 +1,12 @@ +--- +java_rproxy_service_install: False +java_rproxy_service_version: latest +java_rproxy_service_name: reverse-proxy +java_rproxy_group_id: org.gcube.portal.rproxy +java_rproxy_service_extension: war +java_rproxy_service_file: '{{ java_rproxy_service_name }}-{{ java_rproxy_service_version }}.{{ java_rproxy_service_extension }}' +smartgears_rproxy_base_url: 'http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-snapshots' + +java_rproxy_display_name: 'Java Reverse Proxy Service' +java_rproxy_targets: + - { servlet_name: 'ReverseProxy', target_uri: 'https://revproxied-app.example.org/', log: 'true', forwardip: 'true', preserve_host: 'true', preserve_cookies: 'true', handle_redirects: 'true', socket_timeout: '60000', read_timeout: '60000', url_pattern: [ '/dest1/*', '/dest2/*' ] } \ No newline at end of file diff --git a/smartgears/java_reverse_proxy/tasks/main.yml b/smartgears/java_reverse_proxy/tasks/main.yml new file mode 100644 index 0000000..6392073 --- /dev/null +++ b/smartgears/java_reverse_proxy/tasks/main.yml @@ -0,0 +1,49 @@ +--- +- block: + - name: Remove the old java_rproxy service files + file: path={{ item }} state=absent + with_items: + - '{{ smartgears_instance_path }}/webapps/{{ java_rproxy_service_name }}' + - '{{ smartgears_instance_path }}/webapps/{{ java_rproxy_service_name }}.{{ java_rproxy_service_extension }}' + notify: Restart smartgears + + become: True + become_user: '{{ d4science_user }}' + when: not java_rproxy_service_install + tags: [ 'smartgears', 'java_rproxy_service', 'tomcat' ] + +- block: + - name: Get the java_rproxy-service war + #maven_artifact: artifact_id={{ java_rproxy_service_name }} version={{ java_rproxy_service_version | default(omit) }} group_id={{ java_rproxy_group_id }} extension={{ java_rproxy_service_extension | default('war') }} repository_url={{ smartgears_global_base_url }} dest={{ smartgears_downloads_dir }}/{{ java_rproxy_service_file }} verify_checksum=always + maven_artifact: artifact_id={{ java_rproxy_service_name }} version={{ java_rproxy_service_version | default(omit) }} group_id={{ java_rproxy_group_id }} extension={{ java_rproxy_service_extension | default('war') }} repository_url={{ smartgears_rproxy_base_url }} dest={{ smartgears_downloads_dir }}/{{ java_rproxy_service_file }} verify_checksum=always + register: java_rproxy_service_download + + - name: Remove the old java_rproxy service files + file: path={{ item }} state=absent + with_items: + - '{{ smartgears_instance_path }}/webapps/{{ java_rproxy_service_name }}' + - '{{ smartgears_instance_path }}/webapps/{{ java_rproxy_service_name }}.{{ java_rproxy_service_extension }}' + notify: Restart smartgears + when: java_rproxy_service_download is changed + + - name: Create the java_rproxy webapp directory + file: dest={{ smartgears_instance_path }}/webapps/{{ java_rproxy_service_name }} state=directory + when: java_rproxy_service_download is changed + + - name: Unarchive the java_rproxy war file + unarchive: copy=no src={{ smartgears_downloads_dir }}/{{ java_rproxy_service_file }} dest={{ smartgears_instance_path }}/webapps/{{ java_rproxy_service_name }} + args: + creates: '{{ smartgears_instance_path }}/webapps/{{ java_rproxy_service_name }}/WEB-INF/web.xml' + notify: Restart smartgears + + - name: Install the java_rproxy web.xml template + template: src=web.xml dest={{ smartgears_instance_path }}/webapps/{{ java_rproxy_service_name }}/WEB-INF/web.xml mode=0440 + notify: Restart smartgears + + +# TODO: unarchive the war file and install the web.xml. + + become: True + become_user: '{{ d4science_user }}' + when: java_rproxy_service_install + tags: [ 'smartgears', 'java_rproxy_service', 'tomcat' ] diff --git a/smartgears/java_reverse_proxy/templates/web.xml b/smartgears/java_reverse_proxy/templates/web.xml new file mode 100644 index 0000000..e2f6ffb --- /dev/null +++ b/smartgears/java_reverse_proxy/templates/web.xml @@ -0,0 +1,52 @@ + + + + {{ java_rproxy_display_name }} + {% for servlet in java_rproxy_targets %} + + {{ servlet.servlet_name }} + org.mitre.dsmiley.httpproxy.ProxyServlet + + targetUri + {{ servlet. target_uri }} + + + log + {{ servlet.log }} + + + forwardip + {{ servlet.forwardip }} + + + preserveHost + {{ servlet.preserve_host }} + + + preserveCookies + {{ servlet.preserve_cookies }} + + + http.protocol.handle-redirects + {{ servlet.handle_redirects }} + + + http.socket.timeout + {{ servlet.socket_timeout }} + + + http.read.timeout + {{ servlet.read_timeout }} + + + + {{ servlet.servlet_name }} + {% for pattern in servlet.url_patterns %} + {{ pattern }} + {% endfor %} + + {% endfor %} +