From 65ea24f4bbdb7a204534f10b79c8719cbcb54cb0 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Wed, 12 Oct 2016 21:47:58 -0400 Subject: [PATCH] adds log message for successful connection and disconnection (#17993) The network module will now log a message when it connects to a remote host successfully and specify the transport used. It will also log a message when the module discconnect() method is called. --- lib/ansible/module_utils/network.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/module_utils/network.py b/lib/ansible/module_utils/network.py index 515dd41945d..d60fd6db8fd 100644 --- a/lib/ansible/module_utils/network.py +++ b/lib/ansible/module_utils/network.py @@ -147,6 +147,8 @@ class NetworkModule(AnsibleModule): self.connection.connect(self.params) if self.params['authorize']: self.connection.authorize(self.params) + self.log('connected to %s:%s using %s' % (self.params['host'], + self.params['port'], self.params['transport'])) except NetworkError: exc = get_exception() self.fail_json(msg=exc.message) @@ -155,6 +157,7 @@ class NetworkModule(AnsibleModule): try: if self.connected: self.connection.disconnect() + self.log('disconnected from %s' % self.params['host']) except NetworkError: exc = get_exception() self.fail_json(msg=exc.message)