mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Merge pull request #14967 from ansible/facts-subset-and-cleanup
Facts subset and cleanup
This commit is contained in:
@@ -156,6 +156,7 @@ DEFAULT_PRIVATE_ROLE_VARS = get_config(p, DEFAULTS, 'private_role_vars', 'ANSIBL
|
||||
DEFAULT_JINJA2_EXTENSIONS = get_config(p, DEFAULTS, 'jinja2_extensions', 'ANSIBLE_JINJA2_EXTENSIONS', None)
|
||||
DEFAULT_EXECUTABLE = get_config(p, DEFAULTS, 'executable', 'ANSIBLE_EXECUTABLE', '/bin/sh')
|
||||
DEFAULT_GATHERING = get_config(p, DEFAULTS, 'gathering', 'ANSIBLE_GATHERING', 'implicit').lower()
|
||||
DEFAULT_GATHER_SUBSET = get_config(p, DEFAULTS, 'gather_subset', 'ANSIBLE_GATHER_SUBSET', 'all').lower()
|
||||
DEFAULT_LOG_PATH = get_config(p, DEFAULTS, 'log_path', 'ANSIBLE_LOG_PATH', '', ispath=True)
|
||||
DEFAULT_FORCE_HANDLERS = get_config(p, DEFAULTS, 'force_handlers', 'ANSIBLE_FORCE_HANDLERS', False, boolean=True)
|
||||
DEFAULT_INVENTORY_IGNORE = get_config(p, DEFAULTS, 'inventory_ignore_extensions', 'ANSIBLE_INVENTORY_IGNORE', ["~", ".orig", ".bak", ".ini", ".cfg", ".retry", ".pyc", ".pyo"], islist=True)
|
||||
|
||||
@@ -151,11 +151,20 @@ class PlayIterator:
|
||||
self._play = play
|
||||
self._blocks = []
|
||||
|
||||
# Default options to gather
|
||||
gather_subset = C.DEFAULT_GATHER_SUBSET
|
||||
|
||||
# Retrieve subset to gather
|
||||
if self._play.gather_subset is not None:
|
||||
gather_subset = self._play.gather_subset
|
||||
|
||||
setup_block = Block(play=self._play)
|
||||
setup_task = Task(block=setup_block)
|
||||
setup_task.action = 'setup'
|
||||
setup_task.tags = ['always']
|
||||
setup_task.args = {}
|
||||
setup_task.args = {
|
||||
'gather_subset': gather_subset,
|
||||
}
|
||||
setup_task.set_loader(self._play._loader)
|
||||
setup_block.block = [setup_task]
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -334,7 +334,10 @@ class Base:
|
||||
if value is None:
|
||||
value = []
|
||||
elif not isinstance(value, list):
|
||||
value = [ value ]
|
||||
if isinstance(value, string_types):
|
||||
value = value.split(',')
|
||||
else:
|
||||
value = [ value ]
|
||||
if attribute.listof is not None:
|
||||
for item in value:
|
||||
if not isinstance(item, attribute.listof):
|
||||
@@ -346,11 +349,15 @@ class Base:
|
||||
elif attribute.isa == 'set':
|
||||
if value is None:
|
||||
value = set()
|
||||
else:
|
||||
if not isinstance(value, (list, set)):
|
||||
elif not isinstance(value, (list, set)):
|
||||
if isinstance(value, string_types):
|
||||
value = value.split(',')
|
||||
else:
|
||||
# Making a list like this handles strings of
|
||||
# text and bytes properly
|
||||
value = [ value ]
|
||||
if not isinstance(value, set):
|
||||
value = set(value)
|
||||
if not isinstance(value, set):
|
||||
value = set(value)
|
||||
elif attribute.isa == 'dict':
|
||||
if value is None:
|
||||
value = dict()
|
||||
|
||||
@@ -64,6 +64,7 @@ class Play(Base, Taggable, Become):
|
||||
|
||||
# Connection
|
||||
_gather_facts = FieldAttribute(isa='bool', default=None, always_post_validate=True)
|
||||
_gather_subset = FieldAttribute(isa='list', default=None, always_post_validate=True)
|
||||
_hosts = FieldAttribute(isa='list', required=True, listof=string_types, always_post_validate=True)
|
||||
_name = FieldAttribute(isa='string', default='', always_post_validate=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user