From 47b2cb748b0815ae7680f7be45b64ebf40262e25 Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Thu, 2 May 2019 15:09:15 -0400 Subject: [PATCH] Allow config boolean options to default to None (#55951) * Allow plugin boolean options to default to None * fix mistake * changelog * be more specific --- changelogs/fragments/55951-config-bool-options.yml | 2 ++ lib/ansible/config/manager.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/55951-config-bool-options.yml diff --git a/changelogs/fragments/55951-config-bool-options.yml b/changelogs/fragments/55951-config-bool-options.yml new file mode 100644 index 0000000000..e13043cb37 --- /dev/null +++ b/changelogs/fragments/55951-config-bool-options.yml @@ -0,0 +1,2 @@ +bugfixes: + - Allow config options that are type boolean to default to None rather than only True or False. diff --git a/lib/ansible/config/manager.py b/lib/ansible/config/manager.py index ec3fc8e601..c951e82d58 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -83,11 +83,11 @@ def ensure_type(value, value_type, origin=None): if value_type: value_type = value_type.lower() - if value_type in ('boolean', 'bool'): - value = boolean(value, strict=False) + if value is not None: + if value_type in ('boolean', 'bool'): + value = boolean(value, strict=False) - elif value is not None: - if value_type in ('integer', 'int'): + elif value_type in ('integer', 'int'): value = int(value) elif value_type == 'float':