Debian Codegraph @

lib/ansible/plugins/test/version_compare.yml

raw
1 DOCUMENTATION:
2 name: version
3 author: Ansible Core
4 version_added: "1.6"
5 short_description: compare version strings
6 aliases: [version_compare]
7 description:
8 - Compare version strings using various versioning schemes
9 options:
10 _input:
11 description: Left hand version to compare
12 type: string
13 required: True
14 version:
15 description: Right hand version to compare
16 type: string
17 required: True
18 operator:
19 description: Comparison operator
20 type: string
21 required: False
22 choices:
23 - ==
24 - '='
25 - eq
26 - <
27 - lt
28 - <=
29 - le
30 - '>'
31 - gt
32 - '>='
33 - ge
34 - '!='
35 - <>
36 - ne
37 default: eq
38 strict:
39 description: Whether to use strict version scheme. Mutually exclusive with O(version_type)
40 type: boolean
41 required: False
42 default: False
43 version_type:
44 description: Version scheme to use for comparison. Mutually exclusive with O(strict). See C(notes) for descriptions on the version types.
45 type: string
46 required: False
47 choices:
48 - loose
49 - strict
50 - semver
51 - semantic
52 - pep440
53 default: loose
54 notes:
55 - V(loose) - This type corresponds to the Python C(distutils.version.LooseVersion) class. All version formats are valid for this type. The rules for comparison are simple and predictable, but may not always give expected results.
56 - V(strict) - This type corresponds to the Python C(distutils.version.StrictVersion) class. A version number consists of two or three dot-separated numeric components, with an optional "pre-release" tag on the end. The pre-release tag consists of a single letter C(a) or C(b) followed by a number. If the numeric components of two version numbers are equal, then one with a pre-release tag will always be deemed earlier (lesser) than one without.
57 - V(semver)/V(semantic) - This type implements the L(Semantic Version,https://semver.org) scheme for version comparison.
58 - V(pep440) - This type implements the Python L(PEP-440,https://peps.python.org/pep-0440/) versioning rules for version comparison. Added in version 2.14.
59 EXAMPLES: |
60 - name: version test examples
61 assert:
62 that:
63 - "'1.0' is version_compare('1.0', '==')" # old name
64 - "'1.0' is version('1.0', '==')"
65 - "'1.0' is version('2.0', '!=')"
66 - "'1.0' is version('2.0', '<')"
67 - "'2.0' is version('1.0', '>')"
68 - "'1.0' is version('1.0', '<=')"
69 - "'1.0' is version('1.0', '>=')"
70 - "'1.0' is version_compare('1.0', '==', strict=true)" # old name
71 - "'1.0' is version('1.0', '==', strict=true)"
72 - "'1.0' is version('2.0', '!=', strict=true)"
73 - "'1.0' is version('2.0', '<', strict=true)"
74 - "'2.0' is version('1.0', '>', strict=true)"
75 - "'1.0' is version('1.0', '<=', strict=true)"
76 - "'1.0' is version('1.0', '>=', strict=true)"
77 - "'1.2.3' is version('2.0.0', 'lt', version_type='semver')"
78 - "'2.14.0rc1' is version('2.14.0', 'lt', version_type='pep440')"
79 RETURN:
80 _value:
81 description: Returns V(True) or V(False) depending on the outcome of the comparison.
82 type: boolean