mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
git_config: fix state=absent if value is present (#8452)
* Fix state=absent if value is present. * Update changelog fragment.
This commit is contained in:
parent
0129346eda
commit
2a3819a696
3 changed files with 27 additions and 1 deletions
2
changelogs/fragments/8452-git_config-absent.yml
Normal file
2
changelogs/fragments/8452-git_config-absent.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- "git_config - fix behavior of ``state=absent`` if ``value`` is present (https://github.com/ansible-collections/community.general/issues/8436, https://github.com/ansible-collections/community.general/pull/8452)."
|
|
@ -252,7 +252,7 @@ def main():
|
||||||
module.exit_json(changed=False, msg='', config_value=old_values[0] if old_values else '')
|
module.exit_json(changed=False, msg='', config_value=old_values[0] if old_values else '')
|
||||||
elif unset and not out:
|
elif unset and not out:
|
||||||
module.exit_json(changed=False, msg='no setting to unset')
|
module.exit_json(changed=False, msg='no setting to unset')
|
||||||
elif new_value in old_values and (len(old_values) == 1 or add_mode == "add"):
|
elif new_value in old_values and (len(old_values) == 1 or add_mode == "add") and not unset:
|
||||||
module.exit_json(changed=False, msg="")
|
module.exit_json(changed=False, msg="")
|
||||||
|
|
||||||
# Until this point, the git config was just read and in case no change is needed, the module has already exited.
|
# Until this point, the git config was just read and in case no change is needed, the module has already exited.
|
||||||
|
|
|
@ -18,6 +18,30 @@
|
||||||
scope: "{{ option_scope }}"
|
scope: "{{ option_scope }}"
|
||||||
register: get_result
|
register: get_result
|
||||||
|
|
||||||
|
- name: assert unset changed and deleted value
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- unset_result is changed
|
||||||
|
- unset_result.diff.before == option_value + "\n"
|
||||||
|
- unset_result.diff.after == "\n"
|
||||||
|
- get_result.config_value == ''
|
||||||
|
|
||||||
|
- import_tasks: setup_value.yml
|
||||||
|
|
||||||
|
- name: unsetting value with value specified
|
||||||
|
git_config:
|
||||||
|
name: "{{ option_name }}"
|
||||||
|
scope: "{{ option_scope }}"
|
||||||
|
value: "{{ option_value }}"
|
||||||
|
state: absent
|
||||||
|
register: unset_result
|
||||||
|
|
||||||
|
- name: getting value
|
||||||
|
git_config:
|
||||||
|
name: "{{ option_name }}"
|
||||||
|
scope: "{{ option_scope }}"
|
||||||
|
register: get_result
|
||||||
|
|
||||||
- name: assert unset changed and deleted value
|
- name: assert unset changed and deleted value
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
|
Loading…
Reference in a new issue