Bootstrap FreeKB - Ansible - --connection command line flag
Ansible - --connection command line flag

Updated:   |  Ansible articles

By default, Ansible uses SSH to connect to managed nodes (e.g. target systems).


The ansible-doc command can be used to display the different type of connection plugins that can be used to connect to a managed node, such as SSH, Paramiko SSH, local, and on on. By default, connection_plugins in the main ansible.cfg file is commented out, like this.

#connection_plugins = /usr/share/ansible/plugins/connection


The connection plugins directory, such as /usr/share/ansible/plugins/connection, will contain Python scripts that are used to make a connection to a managed node.

-rw-r--r--. 1 root root 16315 Aug 10 22:22
-rw-r--r--. 1 root root  6868 Aug 10 22:22
-rw-r--r--. 1 root root 23544 Aug 10 22:22
-rw-r--r--. 1 root root 55379 Aug 10 22:22


The --connection command line option can be used to specify the connection plugin that you want to use. In this example, the SSH connection plugin is specified.

ansible-playbook foo.yml --connection=ssh


In this example, the local connection plugin is specified. This will make it so that every task in the foo.yml playbook is run on the control node (your Ansible server).

ansible-playbook foo.yml --connection="local"


Or the connection plugin could be used.

- hosts: all
  connection: local


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter 08fb64 in the box below so that we can be sure you are a human.