/Ansible 2.10

Working with network connection options

Network modules can support multiple connection protocols, such as ansible.netcommon.network_cli, ansible.netcommon.netconf, and ansible.netcommon.httpapi. These connections include some common options you can set to control how the connection to your network device behaves.

Common options are:

Setting timeout options

When communicating with a remote device, you have control over how long Ansible maintains the connection to that device, as well as how long Ansible waits for a command to complete on that device. Each of these options can be set as variables in your playbook files, environment variables, or settings in your ansible.cfg file.

For example, the three options for controlling the connection timeout are as follows.

Using vars (per task):

- name: save running-config
    commands: copy running-config startup-config
      ansible_command_timeout: 30

Using the environment variable:


Using the global configuration (in ansible.cfg)

[persistent_connection ]
command_timeout = 30

See Variable precedence: Where should I put a variable? for details on the relative precedence of each of these variables. See the individual connection type to understand each option.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.