haxorof/ansible-role-docker-ce

Upgrade of docker-compose fails when fetching latest version from Github API

haxorof opened this issue · 1 comments

Version Information

Ansible: core 2.12.4
Role: 3.7.0

Steps to Reproduce

Running the playbook twice towards the same target causes the task to fail:

---
- name: Install latest version of compose using GitHub API
  hosts: test-host
  vars:
    docker_users:
      - vagrant
    docker_compose: true
    docker_compose_no_pip: true
  roles:
    - haxorof.docker_ce

Expected Behavior

Docker compose v2 installed successfully installed the first run and then second run all is ok

Actual Behavior

On second run the following task fail:

TASK [haxorof.docker_ce : Determine if installed docker-compose version needs to be replaced] ***
Sunday 24 April 2022  10:51:05 +0000 (0:00:01.430)       0:03:03.037 **********
fatal: [test-host]: FAILED! => {"msg": "Version comparison failed: '<' not supported between instances of 'str' and 'int'"}

The reason is fails now is that in the docker-compose releases has changed their release versions to be prefixed with v since version 2.0.0. This causes this task to fail since that is not comparable with the version fetched from the docker-compose command.