# Test plugin version error : could not compare 'str' and 'int'

**URL:** <https://forum.ansible.com/t/test-plugin-version-error-could-not-compare-str-and-int/45158>\
**Category:** Get Help\
**Tags:** git, playbook\
**Created:** [January 23, 2026, 1:40pm UTC](https://forum.ansible.com/t/test-plugin-version-error-could-not-compare-str-and-int/45158 "2026-01-23T13:40:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fghebert](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@fghebert](https://forum.ansible.com/u/fghebert)\
**Post date:** [January 23, 2026, 1:40pm UTC](https://forum.ansible.com/t/test-plugin-version-error-could-not-compare-str-and-int/45158/1 "2026-01-23T13:40:30Z")

</div>

Hi,

Here is an abstract of my role:

```auto
- name: Get Git's version
  ansible.builtin.shell: "git --version | awk -F' ' { print $3 }'"
  register: base_git_installed_version
  when: base_git_installed.rc == 0

```

```auto
- name: Debug Git version
  ansible.builtin.debug:
    var: base_git_installed_version

```

```auto
- name: Assert Git version
  ansible.builtin.assert:
    that: "{{ base_git_installed_version|trim is version('1.7.1', 'gt') }}"
    fail_msg: "Git version is not enought for ansible git plugin"

```

I’ve the following error message:

FAILED! =\> {“changed”: false, “msg”: “Task failed: The test plugin ‘ansible.builtin.version’ failed: Version comparison failed: ‘\<’ not supported between instances of ‘str’ and ‘int’”}

I’ve tried many combinations : float filter on both arg inputs, str or int filters, with and without double quotes around the expression, single quotes around inputs. Nothing…

Thx for your help!

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [January 23, 2026, 2:02pm UTC](https://forum.ansible.com/t/test-plugin-version-error-could-not-compare-str-and-int/45158/2 "2026-01-23T14:02:15Z")

</div>

Welcome to _The Forum_, @fghebert!

> [@fghebert](#):
>
> ```auto
> - name: Get Git's version
> ansible.builtin.shell: "git --version | awk -F' ' { print $3 }'"
> register: base_git_installed_version
> when: base_git_installed.rc == 0
> 
> ```

This part isn’t working. `base_git_installed` doesn’t exist. (Missing prior task?)

But beside that, you need to look at the `base_git_installed_version.stdout` or `base_git_installed_version.stdout_lines[0]` to get the datum you want.

```yml
- name: Assert Git version
  ansible.builtin.assert:
    that: "{{ base_git_installed_version.stdout_lines[0] is version('1.7.1', 'gt') }}"
    fail_msg: "Git version is not enought for ansible git plugin"

```

produces

```plaintext
TASK [Debug Git version] *************************
task path: /home/utoddl/ansible/fghebert_00.yml:12
ok: [localhost] => 
  base_git_installed_version:
    changed: true
    cmd: git --version | awk -F' ' '{ print $3 }'
    delta: '0:00:00.004688'
    end: '2026-01-23 09:00:14.357694'
    failed: false
    msg: ''
    rc: 0
    start: '2026-01-23 09:00:14.353006'
    stderr: ''
    stderr_lines: []
    stdout: 2.52.0
    stdout_lines:
    - 2.52.0

TASK [Assert Git version] ************************
task path: /home/utoddl/ansible/fghebert_00.yml:16
ok: [localhost] => changed=false 
  msg: All assertions passed

```

---

<div class="post-metadata">

**Author:** ![fghebert](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@fghebert](https://forum.ansible.com/u/fghebert)\
**Post date:** [January 23, 2026, 2:11pm UTC](https://forum.ansible.com/t/test-plugin-version-error-could-not-compare-str-and-int/45158/4 "2026-01-23T14:11:23Z")

</div>

Hi again,

many many thanks for you so quick reply! Getting the stdout\_lines property works! Wow! Thanks again!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 22, 2026, 2:11pm UTC](https://forum.ansible.com/t/test-plugin-version-error-could-not-compare-str-and-int/45158/5 "2026-02-22T14:11:54Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
