mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 14:01:42 -07:00
Consolidate boolean/mk_boolean conversion functions into a single location
Consolidate the module_utils, constants, and config functions that convert values into booleans into a single function in module_utils. Port code to use the module_utils.validate.convert_bool.boolean function isntead of mk_boolean.
This commit is contained in:
parent
f9c60e1a82
commit
ff22528b07
30 changed files with 433 additions and 102 deletions
|
@ -23,14 +23,11 @@ import fnmatch
|
|||
|
||||
from ansible import constants as C
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.parsing.convert_bool import boolean
|
||||
from ansible.playbook.block import Block
|
||||
from ansible.playbook.task import Task
|
||||
|
||||
|
||||
boolean = C.mk_boolean
|
||||
|
||||
__all__ = ['PlayIterator']
|
||||
|
||||
try:
|
||||
from __main__ import display
|
||||
except ImportError:
|
||||
|
@ -38,6 +35,9 @@ except ImportError:
|
|||
display = Display()
|
||||
|
||||
|
||||
__all__ = ['PlayIterator']
|
||||
|
||||
|
||||
class HostState:
|
||||
def __init__(self, blocks):
|
||||
self._blocks = blocks[:]
|
||||
|
@ -300,10 +300,10 @@ class PlayIterator:
|
|||
# NOT explicitly set gather_facts to False.
|
||||
|
||||
gathering = C.DEFAULT_GATHERING
|
||||
implied = self._play.gather_facts is None or boolean(self._play.gather_facts)
|
||||
implied = self._play.gather_facts is None or boolean(self._play.gather_facts, strict=False)
|
||||
|
||||
if (gathering == 'implicit' and implied) or \
|
||||
(gathering == 'explicit' and boolean(self._play.gather_facts)) or \
|
||||
(gathering == 'explicit' and boolean(self._play.gather_facts, strict=False)) or \
|
||||
(gathering == 'smart' and implied and not (self._variable_manager._fact_cache.get(host.name, {}).get('module_setup', False))):
|
||||
# The setup block is always self._blocks[0], as we inject it
|
||||
# during the play compilation in __init__ above.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue