Our EDI translator is a Java application from a vendor, and it runs on four gateway hosts. The Ansible role installs it with get_url: the URL contains the version, from a variable called translator_version, the destination is /opt/edi-translator/translator.jar, and a handler restarts the service when the task changes.
In October the vendor released 4.2.3 to fix a vulnerability in its XML parsing. We changed translator_version from 4.2.1 to 4.2.3, reviewed it, merged it and ran the play. It was green on all four hosts. Five weeks later our vulnerability scanner reported 4.2.1 on all four.
The task had reported ok, not changed, and the handler never ran. get_url has a force parameter that defaults to no, and the documentation says what that means: the file is only downloaded if the destination does not exist. Our destination existed. The URL is not part of the comparison, and the module has no idea where the existing file came from. A new version number in the URL changed nothing on any host that already had a jar.
Our tests did not catch it because they ran the role once, in a fresh container. A fresh container has no jar, so the download happened and the version check passed. The test proved the first install. Every real host was doing an upgrade.
The task now carries a checksum, sha256 plus the hash the vendor publishes, kept in a variable next to translator_version so the two change in the same commit. With a checksum, get_url compares it with the file already on disk and downloads again when they differ, which also catches a jar somebody replaced by hand. The handler fires on that change. The role's test now runs twice in the same container, first with the previous version and then with the new one, and asserts the version the running service reports. After every play a check compares that reported version with the inventory on all four hosts and fails the run if they differ.
The variable said 4.2.3. The task never looked further than the file name, and the file name had not changed.
– Sergey Shinder
Top comments (0)