ansible-role-haproxy
ansible-role-haproxy copied to clipboard
Version detection on Ubuntu 22.04
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.
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.
I've added a new pull request that should make the version detection a little bit more dynamic as well.
#53
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.
This is fixed via #53.