Add gathering_policy parameter to run_ansible_playbook function
This patch adds a new parameter called 'gathering_policy' (Defaults to None) to the 'run_ansible_playbook' function. This parameter will control the default policy of the Ansible fact gathering. Sets to None by default, it will use the default policy for Ansible (ie. 'implicit'). Change-Id: I0668241a1675dd4e344cc24b6ff2cbb8f93b7a45 Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
@@ -84,7 +84,8 @@ def run_ansible_playbook(logger,
|
||||
skip_tags=None,
|
||||
verbosity=1,
|
||||
extra_vars=None,
|
||||
plan='overcloud'):
|
||||
plan='overcloud',
|
||||
gathering_policy=None):
|
||||
"""Simple wrapper for ansible-playbook
|
||||
|
||||
:param logger: logger instance
|
||||
@@ -147,6 +148,12 @@ def run_ansible_playbook(logger,
|
||||
:param extra_vars: set additional variables as a Dict
|
||||
or the absolute path of a JSON or YAML file type
|
||||
:type extra_vars: Either a Dict or the absolute path of JSON or YAML
|
||||
|
||||
:param gathering_policy: This setting controls the default policy of
|
||||
fact gathering ('smart', 'implicit', 'explicit'). Defaults to None.
|
||||
When not specified, the policy will be the default Ansible one, ie.
|
||||
'implicit'.
|
||||
:type gathering_facts: String
|
||||
"""
|
||||
env = os.environ.copy()
|
||||
|
||||
@@ -177,6 +184,9 @@ def run_ansible_playbook(logger,
|
||||
|
||||
env['ANSIBLE_HOST_KEY_CHECKING'] = 'False'
|
||||
|
||||
if gathering_policy in ['smart', 'explicit', 'implicit']:
|
||||
env['ANSIBLE_GATHERING'] = gathering_policy
|
||||
|
||||
if extra_vars is None:
|
||||
extra_vars = {}
|
||||
|
||||
|
Reference in New Issue
Block a user