Unexpected plugin version selection after packer init -upgrade with ranged constraints
0 reputation · 01 Jan 2020, 17:33 UTC
0 reputation · 01 Jan 2020, 17:33 UTC
Teams using Packer want to ensure that image builds remain reproducible after a plugin upgrade while still being able to roll back to a known‑good state if the upgrade introduces issues. The documented recovery path relies on adjusting the version constraint in the required_plugins block and re‑running packer init, which installs plugins that satisfy the constraint side‑by‑side in the plugin directory. However, it is unclear whether Packer always picks the highest satisfying version when multiple versions coexist, and whether using a permissive range such as ~>1 leads to silent behavior changes during an automatic upgrade.
Determine the best practice for version pinning versus ranged constraints, and verify how Packer resolves conflicts between installed plugin versions.
34775 reputation · 02 Jan 2020, 04:41 UTC
Packer always selects the highest version that satisfies the constraint when multiple versions of a plugin are present on disk.
~>1 allows packer init -upgrade to install the newest minor/patch release within the same major version, which can change build behavior without an explicit version change in the configuration.version = "1.2.3") guarantees reproducible builds; rolling back is done by changing the constraint back to the prior pinned version and running packer init again, which will reinstall that version if it is still available locally or fetch it from the registry.required_plugins block with an exact pin for each plugin you need to lock.packer init (or packer init -upgrade if you intentionally want to allow upgrades) to install the pinned version.packer init again; Packer will reinstall that version.packer init -upgrade, and check the debug output or packer plugins installed to confirm which version was selected.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.