mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-31 17:11:23 -07:00
Fix mixed type comparison resulting in wrong changed
(#2772)
When using `use_max` or `use_min` in `pam_limits`, the new value is an integer compared with the actual_value which is a string, so they are always different and the module reports a changed but none occurred.
This commit is contained in:
parent
839adc208f
commit
f06e2e7a0b
1 changed files with 4 additions and 4 deletions
|
@ -194,7 +194,7 @@ def main():
|
||||||
|
|
||||||
if use_max:
|
if use_max:
|
||||||
if value.isdigit() and actual_value.isdigit():
|
if value.isdigit() and actual_value.isdigit():
|
||||||
new_value = max(int(value), int(actual_value))
|
new_value = str(max(int(value), int(actual_value)))
|
||||||
elif actual_value_unlimited:
|
elif actual_value_unlimited:
|
||||||
new_value = actual_value
|
new_value = actual_value
|
||||||
else:
|
else:
|
||||||
|
@ -202,7 +202,7 @@ def main():
|
||||||
|
|
||||||
if use_min:
|
if use_min:
|
||||||
if value.isdigit() and actual_value.isdigit():
|
if value.isdigit() and actual_value.isdigit():
|
||||||
new_value = min(int(value), int(actual_value))
|
new_value = str(min(int(value), int(actual_value)))
|
||||||
elif value_unlimited:
|
elif value_unlimited:
|
||||||
new_value = actual_value
|
new_value = actual_value
|
||||||
else:
|
else:
|
||||||
|
@ -211,7 +211,7 @@ def main():
|
||||||
# Change line only if value has changed
|
# Change line only if value has changed
|
||||||
if new_value != actual_value:
|
if new_value != actual_value:
|
||||||
changed = True
|
changed = True
|
||||||
new_limit = domain + "\t" + limit_type + "\t" + limit_item + "\t" + str(new_value) + "\n"
|
new_limit = domain + "\t" + limit_type + "\t" + limit_item + "\t" + new_value + new_comment + "\n"
|
||||||
message = new_limit
|
message = new_limit
|
||||||
nf.write(new_limit)
|
nf.write(new_limit)
|
||||||
else:
|
else:
|
||||||
|
@ -222,7 +222,7 @@ def main():
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
changed = True
|
changed = True
|
||||||
new_limit = domain + "\t" + limit_type + "\t" + limit_item + "\t" + str(new_value) + "\n"
|
new_limit = domain + "\t" + limit_type + "\t" + limit_item + "\t" + new_value + new_comment + "\n"
|
||||||
message = new_limit
|
message = new_limit
|
||||||
nf.write(new_limit)
|
nf.write(new_limit)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue