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.
(cherry picked from commit 65ea24f4bb
)
This commit is contained in:
parent
1acd258931
commit
edff94f96d
1 changed files with 3 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue