Skip to content

Commit

Permalink
fix: make type conversions work correctly (related ansible#14487) (an…
Browse files Browse the repository at this point in the history
…sible#14489)

Signed-off-by: kurokobo <2920259+kurokobo@users.noreply.github.com>
Co-authored-by: Alan Rominger <arominge@redhat.com>
  • Loading branch information
2 people authored and djyasin committed Nov 11, 2024
1 parent 2e76953 commit a1c3919
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion awx_collection/plugins/modules/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def coerce_type(module, value):
if not HAS_YAML:
module.fail_json(msg="yaml is not installed, try 'pip install pyyaml'")
return yaml.safe_load(value)
elif value.lower in ('true', 'false', 't', 'f'):
elif value.lower() in ('true', 'false', 't', 'f'):
return {'t': True, 'f': False}[value[0].lower()]
try:
return int(value)
Expand Down
38 changes: 38 additions & 0 deletions awx_collection/tests/integration/targets/settings/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
---
- name: Initialize starting project vvv setting to false
awx.awx.settings:
name: "PROJECT_UPDATE_VVV"
value: false

- name: Change project vvv setting to true
awx.awx.settings:
name: "PROJECT_UPDATE_VVV"
value: true
register: result

- name: Changing setting to true should have changed the value
assert:
that:
- "result is changed"

- name: Change project vvv setting to true
awx.awx.settings:
name: "PROJECT_UPDATE_VVV"
value: true
register: result

- name: Changing setting to true again should not change the value
assert:
that:
- "result is not changed"

- name: Change project vvv setting back to false
awx.awx.settings:
name: "PROJECT_UPDATE_VVV"
value: false
register: result

- name: Changing setting back to false should have changed the value
assert:
that:
- "result is changed"

- name: Set the value of AWX_ISOLATION_SHOW_PATHS to a baseline
settings:
name: AWX_ISOLATION_SHOW_PATHS
Expand Down

0 comments on commit a1c3919

Please sign in to comment.