check options exist before forcing assignment

This commit is contained in:
Brian Coca 2017-06-23 15:56:16 -04:00
parent e1416138f9
commit 0209685f8d

View file

@ -121,6 +121,7 @@ def merge_hash(a, b):
def load_extra_vars(loader, options): def load_extra_vars(loader, options):
extra_vars = {} extra_vars = {}
if hasattr(options, 'extra_vars'):
for extra_vars_opt in options.extra_vars: for extra_vars_opt in options.extra_vars:
data = None data = None
extra_vars_opt = to_text(extra_vars_opt, errors='surrogate_or_strict') extra_vars_opt = to_text(extra_vars_opt, errors='surrogate_or_strict')
@ -146,6 +147,7 @@ def load_options_vars(options, version):
options_vars = {} options_vars = {}
# For now only return check mode, but we can easily return more # For now only return check mode, but we can easily return more
# options if we need variables for them # options if we need variables for them
if hasattr(options, 'check'):
options_vars['ansible_check_mode'] = options.check options_vars['ansible_check_mode'] = options.check
options_vars['ansible_version'] = version options_vars['ansible_version'] = version
return options_vars return options_vars