diff options
author | Andrew Butcher <abutcher@redhat.com> | 2017-05-01 14:24:30 -0400 |
---|---|---|
committer | Andrew Butcher <abutcher@redhat.com> | 2017-05-02 11:22:04 -0400 |
commit | fb16c946f7ec37c615e976faadf726151b75d386 (patch) | |
tree | 45d10ff4ee843190e2d91d400972a7c959886a3a | |
parent | b3180189b9b79aecf319d95e270a4917acf50efc (diff) | |
download | openshift-fb16c946f7ec37c615e976faadf726151b75d386.tar.gz openshift-fb16c946f7ec37c615e976faadf726151b75d386.tar.bz2 openshift-fb16c946f7ec37c615e976faadf726151b75d386.tar.xz openshift-fb16c946f7ec37c615e976faadf726151b75d386.zip |
Refactor system fact gathering to avoid dictionary size change during iteration.
-rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index ca0279426..ec4014e60 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1911,14 +1911,16 @@ class OpenShiftFacts(object): ) self.role = role + # Collect system facts and preface each fact with 'ansible_'. try: - # ansible-2.1 # pylint: disable=too-many-function-args,invalid-name self.system_facts = ansible_facts(module, ['hardware', 'network', 'virtual', 'facter']) # noqa: F405 + additional_facts = {} for (k, v) in self.system_facts.items(): - self.system_facts["ansible_%s" % k.replace('-', '_')] = v + additional_facts["ansible_%s" % k.replace('-', '_')] = v + self.system_facts.update(additional_facts) except UnboundLocalError: - # ansible-2.2 + # ansible-2.2,2.3 self.system_facts = get_all_facts(module)['ansible_facts'] # noqa: F405 self.facts = self.generate_facts(local_facts, |