Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
None
-
Night's Watch
-
2
-
NW - 2021-10-06, NW - 2021-10-20
-
Needs Assessment
-
Bug Fix
-
versioncmp() strips redundant numbers
-
Needs Assessment
Description
Puppet Version: 6.24.0
Puppet Server Version: none
OS Name/Version: Debian 11
while debugging https://github.com/puppetlabs/puppetlabs-apache/pull/2186 i noticed that versioncmp('11.0', '11') doesn't return 0, it returns 1. Is that expected?
Desired Behavior:
I think 11.0 and 11 should be treated as equal
Actual Behavior:
versioncmp() thinks 11.0 is greater than 11
to debug:
notify { "operatingsystemrelease compared to 11: ${versioncmp($::operatingsystemrelease, '11')}":
|
}
|
notify { "operatingsystemmajrelease compared to 11: ${versioncmp($::operatingsystemmajrelease, '11')}":
|
}
|
notify { "operatingsystemrelease: ${::operatingsystemrelease}":
|
}
|
notify { "operatingsystemmajrelease: ${::operatingsystemrelease}":
|
}
|
which brings us:
puppet apply test.pp
|
Notice: Compiled catalog for blal in environment production in 0.02 seconds
|
Notice: operatingsystemrelease compared to 11: 1
|
Notice: /Stage[main]/Main/Notify[operatingsystemrelease compared to 11: 1]/message: defined 'message' as 'operatingsystemrelease compared to 11: 1'
|
Notice: operatingsystemmajrelease compared to 11: 0
|
Notice: /Stage[main]/Main/Notify[operatingsystemmajrelease compared to 11: 0]/message: defined 'message' as 'operatingsystemmajrelease compared to 11: 0'
|
Notice: operatingsystemrelease: 11.0
|
Notice: /Stage[main]/Main/Notify[operatingsystemrelease: 11.0]/message: defined 'message' as 'operatingsystemrelease: 11.0'
|
Notice: operatingsystemmajrelease: 11.0
|
Notice: /Stage[main]/Main/Notify[operatingsystemmajrelease: 11.0]/message: defined 'message' as 'operatingsystemmajrelease: 11.0'
|
Notice: Applied catalog in 0.01 seconds
|
and the facts:
:~> facter operatingsystemmajrelease
|
11
|
:~> facter operatingsystemrelease
|
11.0
|