Support setting persistent command timeout per task basis (#42847)

* Support setting persistent command timeout per task basis

Fixes #42200

*  Add variable `ansible_command_timeout` to `persistent_command_timeout`
   option for `network_cli` and `netconf` connection plugin so that the
   command_timeout can be set per task basis while using `connection=network_cli`
   or `connection=netconf`
   eg:
   ```
   - name: run copy command
     ios_command:
       commands:
       - show version
     vars:
      ansible_command_timeout: 40
   ```

* Modify `ansible-connection` to read command_timeout value from
  connection plugin options.

* Add `ansible_command_timeout` to `persistent_command_timeout`
  option in `persistent` to support `connection=local` so that
  it is backward compatibilty

* To support `connection=local` pass the timeout value as variables
  from persistent connection to `ansible-connection` instead of sending
  it in playcontext

* Fix CI failure

* Fix review comment
This commit is contained in:
Ganesh Nalawade
2018-07-20 10:04:53 +05:30
committed by GitHub
parent 5e20ef1d89
commit 97d4e53131
25 changed files with 72 additions and 34 deletions

View File

@@ -119,7 +119,7 @@ class ConnectionProcess(object):
if not data:
break
signal.alarm(self.connection._play_context.timeout)
signal.alarm(self.connection.get_option('persistent_command_timeout'))
resp = self.srv.handle_request(data)
signal.alarm(0)
@@ -146,7 +146,7 @@ class ConnectionProcess(object):
self.shutdown()
def command_timeout(self, signum, frame):
display.display('command timeout triggered, timeout value is %s secs' % self.play_context.timeout, log_only=True)
display.display('command timeout triggered, timeout value is %s secs' % self.connection.get_option('persistent_command_timeout'), log_only=True)
self.shutdown()
def handler(self, signum, frame):
@@ -273,6 +273,7 @@ def main():
else:
messages.append('found existing local domain socket, using it!')
conn = Connection(socket_path)
conn.set_options(var_options=variables)
pc_data = to_text(init_data)
try:
messages.extend(conn.update_play_context(pc_data))