0

I want to install recent, but not the HEAD. Instead, I'd like to install the most-recent tag of a remote repository -- on the assumption, that this is, what the maintainers consider a "release". Can the git-module do that?

The methods of figuring out the most recent tag are provided here, but they all require for a clone to have happened first.

Is there a way to have the module do "the needful" for me automatically, or must I do it the hard way:

  1. Clone with the git-module.
  2. Find the latest tag with the command-module.
  3. Use another git-task to switch to the tag?
Mikhail T.
  • 2,338
  • 1
  • 24
  • 55

1 Answers1

0

No. Ansible git module requires one commit-ish as the version parameter. One tag, a branch, a commit hash, or HEAD.

How would you sort the tags, committerdate, refname? Actually could be non trivial. The authors could maintain multiple branches in one repo. A previous version backport might commit later. Also, version "number" strings are annoying to sort correctly, git tag --sort=refname might order things in an undesirable way:

v2.8.2
v2.8.20
v2.8.20rc1
v2.8.3

Forget git for a moment, it is not the best deployment tool. Install releases with a package manager that has version numbers and dependency resolution. If a package does not exist, write one yourself, perhaps following the guidelines for your OS distro of choice.

To continue with git anyway, provide the git module a commit-ish that will resolve to the latest stable that you want. Such as a maintenance branch. Create such a branch if it does not exist, on the tag you want. Keep updating this branch as new versions are released.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34
  • The repositories are _many_, but none of them are _mine_. I cannot change them. But I can query each for the most-recently created tag. Ordered by time. The link in my question explains, how this can be done. But, I guess, Ansible's `git`-module cannot do that :( – Mikhail T. May 31 '21 at 02:21
  • Consider making your own clones of the upstream repos that has maintenance branches you advance as desired. Deploy from your git repo. Not the only way to do it, you could write a shell script to sort tags. However, my answer is idempotent modules, so `git` or `package` or `pip` – John Mahowald May 31 '21 at 13:30