aboutsummaryrefslogtreecommitdiff
path: root/ansible/library
diff options
context:
space:
mode:
authorVictor Coutellier <victor.coutellier@gmail.com>2019-03-10 19:07:00 +0100
committerVictor Coutellier <victor.coutellier@gmail.com>2019-03-10 19:13:00 +0100
commit3bb4c199817c8aa4ecd4ae684bd28f84933fb14d (patch)
tree59560f389de64819f94475505b9997e509108db6 /ansible/library
parentf637d139d2d68d3d410bf68c04ed445e983d5e3e (diff)
downloadkolla-ansible-3bb4c199817c8aa4ecd4ae684bd28f84933fb14d.tar.gz
kolla-ansible-3bb4c199817c8aa4ecd4ae684bd28f84933fb14d.zip
Fix kolla-docker possible undefined variable
It is possible to reference undefined variable in kolla-docker module if DockerWorker object initialization fail, so the current behaviour will crash the playbook with the unwanted error message : UnboundLocalError: local variable 'dw' referenced before assignment Change-Id: Ic8d26b11f93255220888b5406f8ab4a6f81736c2 Closes-Bug: #1819361
Diffstat (limited to 'ansible/library')
-rw-r--r--ansible/library/kolla_docker.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py
index 38c090077..063e24091 100644
--- a/ansible/library/kolla_docker.py
+++ b/ansible/library/kolla_docker.py
@@ -974,6 +974,7 @@ def generate_module():
def main():
module = generate_module()
+ dw = None
try:
dw = DockerWorker(module)
# TODO(inc0): We keep it bool to have ansible deal with consistent
@@ -983,7 +984,7 @@ def main():
module.exit_json(changed=dw.changed, result=result, **dw.result)
except Exception:
module.fail_json(changed=True, msg=repr(traceback.format_exc()),
- **dw.result)
+ **getattr(dw, 'result', {}))
if __name__ == '__main__':