expose soem options as vars (#30379)

* expose some useful options as vars for plays and plugins
This commit is contained in:
Brian Coca 2017-09-17 12:25:56 -04:00 committed by GitHub
parent 96ebfd78af
commit 6e857468a2

View file

@ -144,12 +144,19 @@ def load_extra_vars(loader, options):
def load_options_vars(options, version): def load_options_vars(options, version):
options_vars = {}
# For now only return check mode, but we can easily return more options_vars = {'ansible_version': version}
# options if we need variables for them aliases = {'check': 'check_mode',
if hasattr(options, 'check'): 'diff': 'diff_mode',
options_vars['ansible_check_mode'] = options.check 'inventory': 'inventory_sources',
options_vars['ansible_version'] = version 'subset': 'limit',
'tags': 'run_tags'}
for attr in ('check', 'diff', 'forks', 'inventory', 'skip_tags', 'subset', 'tags'):
opt = getattr(options, attr, None)
if opt is not None:
options_vars['ansible_%s' % aliases.get(attr, attr)] = opt
return options_vars return options_vars