ansible-role-haproxy icon indicating copy to clipboard operation
ansible-role-haproxy copied to clipboard

Version detection on Ubuntu 22.04

Open danielsreichenbach opened this issue 2 years ago • 1 comments

Using this role with default settings on Ubuntu 22.04 will cause an error when executing the Set HAProxy version. task due to the version reported by haproxy -v being different.

What is happening

When querying the version - not sure if this is because of Ubuntu 22.04 or HAProxy 2.x - the version string will come back as

HAProxy version 2.4.14-1ubuntu1 2022/02/28 - https://haproxy.org/

Fixing it

A temporary fix for the would be to simply modify the task to look for a different version string like

- name: Set HAProxy version.
  set_fact:
    haproxy_version: '{{ haproxy_version_result.stdout_lines[0] | regex_replace("^HAProxy version ([0-9]\.[0-9]).*$", "\1") }}'

If the HAProxy version string is different between versions, it might be an idea to have variables per OS-Release to parse this.

danielsreichenbach avatar Sep 04 '22 07:09 danielsreichenbach

I ran into the same issue when trying to deploy HaProxy 2.4 on AlmaLinux 9 with the resulting exception.

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleFilterError: Version comparison failed: '<' not supported between instances of 'str' and 'int'

Here is some example version tags which should match the modified regex in the PR.
HA-Proxy version 1.5.18 2016/05/10 HAProxy version 2.4.14-1ubuntu1 2022/02/28 - https://haproxy.org/

The linked PR with the updated regex resolved my issue and should retain backwards compatibility.

corym-vermeer avatar Sep 23 '22 14:09 corym-vermeer

I've added a new pull request that should make the version detection a little bit more dynamic as well.

#53

abaddon82 avatar Oct 18 '22 09:10 abaddon82

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

stale[bot] avatar Jan 22 '23 01:01 stale[bot]

This is fixed via #53.

geerlingguy avatar Jan 23 '23 02:01 geerlingguy