From 5fe10915a85d1768b3d549e069186bd7205ecfa6 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 23 Apr 2023 18:49:32 +0200 Subject: [PATCH] [PR #6404/e49c6a33 backport][stable-6] ini_file: removing required=true for 'section' option (#6411) ini_file: removing required=true for 'section' option (#6404) Fix ini_file by removing required=true for 'section' option. (cherry picked from commit e49c6a339ea76272c34f711fe055594682252db8) Co-authored-by: Felix Fontein --- changelogs/fragments/6404-ini_file-section.yml | 2 ++ plugins/modules/ini_file.py | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/6404-ini_file-section.yml diff --git a/changelogs/fragments/6404-ini_file-section.yml b/changelogs/fragments/6404-ini_file-section.yml new file mode 100644 index 0000000000..b9e8a10e76 --- /dev/null +++ b/changelogs/fragments/6404-ini_file-section.yml @@ -0,0 +1,2 @@ +bugfixes: + - "ini_file - make ``section`` parameter not required so it is possible to pass ``null`` as a value. This only was possible in the past due to a bug in ansible-core that now has been fixed (https://github.com/ansible-collections/community.general/pull/6404)." diff --git a/plugins/modules/ini_file.py b/plugins/modules/ini_file.py index 231a0e836a..9e4c370dc5 100644 --- a/plugins/modules/ini_file.py +++ b/plugins/modules/ini_file.py @@ -42,10 +42,9 @@ options: description: - Section name in INI file. This is added if I(state=present) automatically when a single value is being set. - - If left empty or set to C(null), the I(option) will be placed before the first I(section). + - If left empty, being omitted, or being set to C(null), the I(option) will be placed before the first I(section). - Using C(null) is also required if the config format does not support sections. type: str - required: true option: description: - If set (required for changing a I(value)), this is the name of the option. @@ -430,7 +429,7 @@ def main(): module = AnsibleModule( argument_spec=dict( path=dict(type='path', required=True, aliases=['dest']), - section=dict(type='str', required=True), + section=dict(type='str'), option=dict(type='str'), value=dict(type='str'), values=dict(type='list', elements='str'),