Ansible - --connection command line flag

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


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

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


Web design by yours truely - me, myself, and I   |   |