diff --git a/README.md b/README.md index 3637db8..4bd2746 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,22 @@ 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 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 +users_system_users: + - { login: 'foo', name: "Foo Bar", home: '{{ users_home_dir }}', createhome: 'yes', ssh_key: '{{ foo_ssh_key }}', shell: '/bin/bash', admin: False, log_as_root: False } +``` 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 } +None License ------- @@ -35,4 +26,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..b0ad3d3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,38 @@ --- -# defaults file for ansible-role-template \ No newline at end of file +geoserver_install: True +geoserver_major_version: '2.10' +geoserver_minor_version: 5 +geoserver_app_name: GeoServer +geoserver_version: '{{ geoserver_major_version }}.{{ geoserver_minor_version }}' +geoserver_download_url: 'http://sourceforge.net/projects/geoserver/files/GeoServer/{{ geoserver_version }}/geoserver-{{ geoserver_version }}-war.zip' + +geoserver_additional_jars: False + +geoserver_download_directory: /srv/geoserver +geoserver_create_data_dir: True +geoserver_data_directory: /srv/geoserver_data +geoserver_log_directory: /var/log/geoserver +geoserver_instance_path: '{{ tomcat_m_instances_base_path }}/{{ tomcat_m_instances_port }}' + +geoserver_spatial_install: False +geoserver_spatial_url: 'http://ares.boundlessgeo.com/geoserver/{{ geoserver_major_version }}.x/community-latest/geoserver-{{ geoserver_major_version }}-SNAPSHOT-spatialite-plugin.zip' + +geoserver_spatial_dpkg_requirements: + - libgeos-c1 + - libproj0 + - proj-bin + - libspatialite5 + +geoserver_spatial_db_dir: /srv/geoserver_spatialite/data + +geoserver_marlin_renderer: False +geoserver_marlin_renderer_tag: '0_9_4_3' +geoserver_marlin_renderer_version: '0.9.4.3' +geoserver_marlin_jar_name: 'marlin-{{ geoserver_marlin_renderer_version }}-Unsafe.jar' +geoserver_marlin_java2d_jar_name: 'marlin-{{ geoserver_marlin_renderer_version }}-Unsafe-sun-java2d.jar' +geoserver_marlin_renderer_github_base: "https://github.com/bourgesl/marlin-renderer/releases/tag/v{{ geoserver_marlin_renderer_tag }}" +geoserver_marlin_renderer_github_java2d_url: "https://github-production-release-asset-2e65be.s3.amazonaws.com/16202089/ee528f80-35f1-11ea-969e-f87a9c66a2ee?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201126%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201126T132733Z&X-Amz-Expires=300&X-Amz-Signature=e4b6e69f3b23c16387976a747c9838358acb15ba68ddf0e382f8e22bffef1412&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=16202089&response-content-disposition=attachment%3B%20filename%3Dmarlin-0.9.4.3-Unsafe-sun-java2d.jar&response-content-type=application%2Foctet-stream" +geoserver_marlin_renderer_github_url: "https://github-production-release-asset-2e65be.s3.amazonaws.com/16202089/edb9f900-35f1-11ea-91e8-52082b939e33?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201126%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201126T132427Z&X-Amz-Expires=300&X-Amz-Signature=811102c4311fa0008fb3904f60c383378b5877b06a099bafb1c8919cf5cf0cbd&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=16202089&response-content-disposition=attachment%3B%20filename%3Dmarlin-0.9.4.3-Unsafe.jar&response-content-type=application%2Foctet-stream" +geoserver_marlin_renderer_java_options: "-Xbootclasspath/a:{{ geoserver_instance_path }}/webapps/geoserver/WEB-INF/lib/marlin*.jar -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine" + +# \ No newline at end of file diff --git a/meta/main.yml b/meta/main.yml index 81bda14..385b207 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,46 +1,28 @@ galaxy_info: - author: your name - description: your description - company: your company (optional) + 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://support.d4science.org/projects/automatic-provisioning/issues + issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning - 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: Ubuntu - versions: - - bionic + - name: Ubuntu + versions: + - bionic - 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: + - geoserver + +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 -dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. \ No newline at end of file diff --git a/tasks/geoserver-spatialite.yml b/tasks/geoserver-spatialite.yml new file mode 100644 index 0000000..85ceb2a --- /dev/null +++ b/tasks/geoserver-spatialite.yml @@ -0,0 +1,25 @@ +--- +- block: + - name: Install the PROJ.4 deb packages required by the Geoserver spatialite extension + apt: pkg={{ geoserver_spatial_dpkg_requirements }} state=present update_cache=yes cache_valid_time=3600 + + - name: Download and unpack the Geoserver spatialite extension + unarchive: copy=no src={{ geoserver_spatial_url }} dest={{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }}/WEB-INF/lib/ creates={{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }}/WEB-INF/lib/spatialite-jdbc-3.7.2-2.4.jar owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + - name: Create the data directory where sqlite will store its files + file: dest={{ geoserver_spatial_db_dir }} state=directory owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + + when: geoserver_spatial_install + tags: [ 'geoserver', 'spatialite' ] + +- block: + - name: Remove the Geoserver spatialite data directory + file: path={{ item }} state=absent + with_items: + - '{{ geoserver_spatial_db_dir }}' + + when: not geoserver_spatial_install + tags: [ 'geoserver', 'spatialite' ] diff --git a/tasks/geoserver.yml b/tasks/geoserver.yml new file mode 100644 index 0000000..d3380b6 --- /dev/null +++ b/tasks/geoserver.yml @@ -0,0 +1,79 @@ +--- +- block: + - name: Create the Geoserver download directory + file: path={{ geoserver_download_directory }} state=directory + + - name: Create the Geoserver webapp directory + file: path={{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }} state=directory owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + + - name: Create the Geoserver data directory + file: path={{ geoserver_data_directory }} state=directory owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + when: geoserver_create_data_dir + + - name: Create the Geoserver log directory + file: path={{ geoserver_log_directory }} state=directory owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + + - name: Download the Geoserver file distribution + get_url: url={{ geoserver_download_url }} dest={{ geoserver_download_directory }} validate_certs=False + register: geoserver_download + + - name: Remove the old geoserver war files + file: dest={{ geoserver_download_directory }}/{{ item }} state=absent + with_items: + - geoserver.war + - target + when: geoserver_download is changed + + - name: Unpack the Geoserver zip file + unarchive: copy=no src={{ geoserver_download_directory }}/geoserver-{{ geoserver_version }}-war.zip dest={{ geoserver_download_directory }} creates={{ geoserver_download_directory }}/geoserver.war + + - name: Remove the old geoserver instance if it is present + file: dest={{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }} state=absent + with_items: '{{ tomcat_m_instances }}' + when: geoserver_download is changed + + - name: Create the Geoserver webapp directory + file: path={{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }} state=directory owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + + - name: Unpack the Geoserver war file + unarchive: copy=no src={{ geoserver_download_directory }}/geoserver.war dest={{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }} creates={{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }}/WEB-INF/lib owner={{ item.user }} group={{ item.user }} + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + - name: Remove the postgres jdbc driver when we want a JNDI profile + shell: rm -f {{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }}/WEB-INF/lib/postgresql*.jdbc*.jar + with_items: '{{ tomcat_m_instances }}' + when: tomcat_install_pg_jdbc + notify: tomcat instances restart + + - name: Download newer jar files when needed + get_url: url={{ item.1.url }} dest={{ item.0.instance_path }}/webapps/{{ geoserver_app_name | lower }}/WEB-INF/lib/{{ item.1.file }} owner={{ item.0.user }} group={{ item.0.user }} force=yes + with_together: + - '{{ tomcat_m_instances }}' + - '{{ geoserver_patches_data | default (omit) }}' + when: geoserver_additional_jars + notify: tomcat instances restart + tags: [ 'geoserver', 'geopatch' ] + + when: geoserver_install + tags: geoserver + +- block: + - name: Remove the Geoserver webapp directory + file: path={{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }} state=absent + with_items: '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + - name: Remove the Geoserver download and data directories + file: path={{ item }} state=absent + with_items: + - '{{ geoserver_download_directory }}' + - '{{ geoserver_data_directory }}' + + when: not geoserver_install + tags: geoserver + diff --git a/tasks/main.yml b/tasks/main.yml index 53c6cae..98d068b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,8 @@ --- -# tasks file for ansible-role-template \ No newline at end of file +- import_tasks: geoserver.yml +- import_tasks: geoserver-spatialite.yml + when: geoserver_spatial_install +- import_tasks: marlin-renderer.yml + when: geoserver_marlin_renderer + + diff --git a/tasks/marlin-renderer.yml b/tasks/marlin-renderer.yml new file mode 100644 index 0000000..49bf257 --- /dev/null +++ b/tasks/marlin-renderer.yml @@ -0,0 +1,27 @@ +--- +- name: Manage the marlin renderer + block: + - set_fact: + ansible_python_interpreter: /usr/bin/python3.6 + when: ansible_distribution_release == "trusty" + + - name: Download the marlin renderer jar file + get_url: url={{ geoserver_marlin_renderer_github_url }} dest={{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }}/WEB-INF/lib/{{ geoserver_marlin_jar_name }} owner={{ item.user }} group={{ item.user }} force=yes + with_items: + - '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + - name: Download the marlin renderer jar java2d file + get_url: url={{ geoserver_marlin_renderer_github_java2d_url }} dest={{ item.instance_path }}/webapps/{{ geoserver_app_name | lower }}/WEB-INF/lib/{{ geoserver_marlin_java2d_jar_name }} owner={{ item.user }} group={{ item.user }} force=yes + with_items: + - '{{ tomcat_m_instances }}' + notify: tomcat instances restart + + - set_fact: + ansible_python_interpreter: /usr/bin/python + when: ansible_distribution_release == "trusty" + + when: + - geoserver_install + - geoserver_marlin_renderer + tags: [ 'geoserver', 'geoserver_marlin' ]