Fixes unused var and avoid reassigning keys

Changed code so key doesn't get reassigned in loop
Made use of filtr variable
reviewable/pr18780/r1
Michel Blanc 12 years ago
parent d7385263e3
commit e7ff689fda

14
setup

@ -1105,9 +1105,9 @@ def run_setup(module):
filtr = module.params['filter'] filtr = module.params['filter']
for (k, v) in facts.items(): for (k, v) in facts.items():
k = "ansible_%s" % k.replace('-', '_') k2 = "ansible_%s" % k.replace('-', '_')
if fnmatch.fnmatch(k, module.params['filter']): if fnmatch.fnmatch(k2, filtr):
setup_options[k] = v setup_options[k2] = v
# if facter is installed, and we can use --json because # if facter is installed, and we can use --json because
# ruby-json is ALSO installed, include facter data in the JSON # ruby-json is ALSO installed, include facter data in the JSON
@ -1121,9 +1121,9 @@ def run_setup(module):
facter = False facter = False
if facter: if facter:
for (k,v) in facter_ds.items(): for (k,v) in facter_ds.items():
k = "facter_%s" % k k2 = "facter_%s" % k
if fnmatch.fnmatch(k, module.params['filter']): if fnmatch.fnmatch(k2, filtr):
setup_options[k] = v setup_options[k2] = v
# ditto for ohai, but just top level string keys # ditto for ohai, but just top level string keys
# because it contains a lot of nested stuff we can't use for # because it contains a lot of nested stuff we can't use for
@ -1140,7 +1140,7 @@ def run_setup(module):
for (k,v) in ohai_ds.items(): for (k,v) in ohai_ds.items():
if type(v) == str or type(v) == unicode: if type(v) == str or type(v) == unicode:
k2 = "ohai_%s" % k.replace('-', '_') k2 = "ohai_%s" % k.replace('-', '_')
if fnmatch.fnmatch(k2, module.params['filter']): if fnmatch.fnmatch(k2, filtr):
setup_options[k2] = v setup_options[k2] = v
setup_result = {} setup_result = {}

Loading…
Cancel
Save