I have a simple ansible role and couple of basic tasks within this role. All tasks are defined as local_action
(or delegate_to: localhost
). The host defined in the playbook is also localhost
.
Now when I am running this playbook, it first tries to test ssh connection before executing the role/tasks. This is not a problem but I find it unnecessary to establish or test ssh connection before running a playbook which is explicitly targeting localhost
as host. Following is how my playbook (playbook.yml
) looks like:
- hosts: db-servers
roles:
- role: test
And the role definition (roles/test/tasks/main.yml
) looks as follow:
---
- name: Resolve and copy test configuration
template:
src: "roles/test/templates/temp.conf"
dest: "roles/test/files/temp-4.2.0/temp.conf"
delegate_to: 127.0.0.1
become: no
- name: Run test job
delegate_to: 127.0.0.1
command: roles/test/files/test-4.2.0/test.sh
become: no
Following is my inventory file inv/test
:
[db-servers]
localhost
And I am using this command to run my playbook:
ansible-playbook -i inv/test playbook.yml -vvv
Is there anyway in ansible that I could prevent this ssh connectivity check?
hosts: 127.0.0.1
, thendelegate_to: 127.0.0.1
is unnecessary. – Encarnacion127.0.0.1
in the beginning even the task isdelegate_to: 127.0.0.1
. My target is to avoid this unnecessary ssh completely. – Teressatereteconnection: local
. – Encarnacion