robertdebock / ansible-role-tomcat

Install and configure tomcat on your system.
https://robertdebock.nl/
Apache License 2.0
46 stars 57 forks source link

Compare tar ball checksum to allow tomcat upgrades #47

Open cdm-arm opened 2 years ago

cdm-arm commented 2 years ago

name: Pull request about: This is related to #22 and allows the tomcat role to verify if a newer version was downloaded and upgrade the instance.


Describe the change Calculate the sha1 of the tomcat tarball and verify it with the sha1 of the freshly downloaded tarball. If there is a difference the instance bin folder gets removed to trigger the extracting of the new tarball

Testing Manually tested playbook with:

robertdebock commented 2 years ago

Looks like a good addition, but; it's not idempotent. I guess this tasks is the issue.

cdm-arm commented 2 years ago

Good intention, bad implementation. I changed the way, now utilising the sha512 hashes that Apache anyhow provides.

OyvindLGjesdal commented 1 year ago

Very nice feature @aek-arm and exactly what I was looking for, thanks for posting :)

I think this may pass the CI-actions if the sections with {{ tomcat_directory }}/ is changed to {{ tomcat_directory }}/{{ instance.name }}

I ran a local version with

 - name: stop instance for upgrade
      service:
        name: "{{ instance.name }}"
        state: stopped
      when: slurped_sha512hash.content is defined

at the beginning of the block to avoid any issues with removing stuff during running and checksum for the url seem to fail for older ansible versions, so I use

   checksum: "sha512:{{ tomcat_download_sha512 | regex_replace('\\s[*].+$','') }}}}"

instead.