mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Configurable fact path (#18147)
* Make fact_path configurable * Add docs for fact_path * Add tests for localfacts * Default fact gathering settings in PlayContext
This commit is contained in:
committed by
Brian Coca
parent
f078946ed3
commit
1b2ad94496
@@ -201,6 +201,7 @@ DEFAULT_ROLES_PATH = get_config(p, DEFAULTS, 'roles_path', 'ANSIBLE
|
||||
DEFAULT_REMOTE_TMP = get_config(p, DEFAULTS, 'remote_tmp', 'ANSIBLE_REMOTE_TEMP', '~/.ansible/tmp')
|
||||
DEFAULT_LOCAL_TMP = get_config(p, DEFAULTS, 'local_tmp', 'ANSIBLE_LOCAL_TEMP', '~/.ansible/tmp', value_type='tmppath')
|
||||
DEFAULT_MODULE_NAME = get_config(p, DEFAULTS, 'module_name', None, 'command')
|
||||
DEFAULT_FACT_PATH = get_config(p, DEFAULTS, 'fact_path', 'ANSIBLE_FACT_PATH', None, value_type='path')
|
||||
DEFAULT_FORKS = get_config(p, DEFAULTS, 'forks', 'ANSIBLE_FORKS', 5, value_type='integer')
|
||||
DEFAULT_MODULE_ARGS = get_config(p, DEFAULTS, 'module_args', 'ANSIBLE_MODULE_ARGS', '')
|
||||
DEFAULT_MODULE_LANG = get_config(p, DEFAULTS, 'module_lang', 'ANSIBLE_MODULE_LANG', os.getenv('LANG', 'en_US.UTF-8'))
|
||||
|
||||
@@ -163,8 +163,9 @@ class PlayIterator:
|
||||
self._task_uuid_cache = dict()
|
||||
|
||||
# Default options to gather
|
||||
gather_subset = C.DEFAULT_GATHER_SUBSET
|
||||
gather_timeout = C.DEFAULT_GATHER_TIMEOUT
|
||||
gather_subset = play_context.gather_subset
|
||||
gather_timeout = play_context.gather_timeout
|
||||
fact_path = play_context.fact_path
|
||||
|
||||
# Retrieve subset to gather
|
||||
if self._play.gather_subset is not None:
|
||||
@@ -172,6 +173,9 @@ class PlayIterator:
|
||||
# Retrieve timeout for gather
|
||||
if self._play.gather_timeout is not None:
|
||||
gather_timeout = self._play.gather_timeout
|
||||
# Retrieve fact_path
|
||||
if self._play.fact_path is not None:
|
||||
fact_path = self._play.fact_path
|
||||
|
||||
setup_block = Block(play=self._play)
|
||||
setup_task = Task(block=setup_block)
|
||||
@@ -183,6 +187,8 @@ class PlayIterator:
|
||||
}
|
||||
if gather_timeout:
|
||||
setup_task.args['gather_timeout'] = gather_timeout
|
||||
if fact_path:
|
||||
setup_task.args['fact_path'] = fact_path
|
||||
setup_task.set_loader(self._play._loader)
|
||||
setup_block.block = [setup_task]
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ class Play(Base, Taggable, Become):
|
||||
_accelerate_port = FieldAttribute(isa='int', default=5099, always_post_validate=True)
|
||||
|
||||
# Connection
|
||||
_fact_path = FieldAttribute(isa='string', default=None)
|
||||
_gather_facts = FieldAttribute(isa='bool', default=None, always_post_validate=True)
|
||||
_gather_subset = FieldAttribute(isa='barelist', default=None, always_post_validate=True)
|
||||
_gather_timeout = FieldAttribute(isa='int', default=None, always_post_validate=True)
|
||||
|
||||
@@ -208,6 +208,11 @@ class PlayContext(Base):
|
||||
_step = FieldAttribute(isa='bool', default=False)
|
||||
_diff = FieldAttribute(isa='bool', default=False)
|
||||
|
||||
# Fact gathering settings
|
||||
_gather_subset = FieldAttribute(isa='string', default=C.DEFAULT_GATHER_SUBSET)
|
||||
_gather_timeout = FieldAttribute(isa='string', default=C.DEFAULT_GATHER_TIMEOUT)
|
||||
_fact_path = FieldAttribute(isa='string', default=C.DEFAULT_FACT_PATH)
|
||||
|
||||
def __init__(self, play=None, options=None, passwords=None, connection_lockfd=None):
|
||||
|
||||
super(PlayContext, self).__init__()
|
||||
|
||||
Reference in New Issue
Block a user