# ping inside playbook

**URL:** <https://forum.ansible.com/t/ping-inside-playbook/15506>\
**Category:** Ansible Project\
**Created:** [June 19, 2014, 4:21pm UTC](https://forum.ansible.com/t/ping-inside-playbook/15506 "2014-06-19T16:21:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laurent\_PETIT](https://avatars.discourse-cdn.com/v4/letter/l/8c91f0/32.png) [@Laurent\_PETIT](https://forum.ansible.com/u/Laurent_PETIT)\
**Post date:** [June 19, 2014, 4:21pm UTC](https://forum.ansible.com/t/ping-inside-playbook/15506/1 "2014-06-19T16:21:26Z")

</div>

Hello,

I bootstrap server security from a bootstrap.yml playbook.

Before restarting the ssh service, I’d like to test that it is possible to ssh into the host via the key mechanism (I have used the authorized\_keys module for this purpose).

I’m trying with the ping module as a task, but I’m not sure :

- if I can ask it to not use password authentication and force using private key authentication
- how I can force a specific user (I tried user= without success =\> it is using the user ‘ssh’ ?!?)

Thanks in advance for your insights,

---

<div class="post-metadata">

**Author:** ![Laurent\_PETIT](https://avatars.discourse-cdn.com/v4/letter/l/8c91f0/32.png) [@Laurent\_PETIT](https://forum.ansible.com/u/Laurent_PETIT)\
**Post date:** [June 19, 2014, 4:29pm UTC](https://forum.ansible.com/t/ping-inside-playbook/15506/2 "2014-06-19T16:29:42Z")

</div>

instead of using user=xxx as an argument for the ping module, I use successfully the task remote\_user attribute.

But still, I’m unsure if the test works because I am already connected to the host, or because ansible is using the password I provided via the -k option

---

<div class="post-metadata">

**Author:** ![Laurent\_PETIT](https://avatars.discourse-cdn.com/v4/letter/l/8c91f0/32.png) [@Laurent\_PETIT](https://forum.ansible.com/u/Laurent_PETIT)\
**Post date:** [June 19, 2014, 4:50pm UTC](https://forum.ansible.com/t/ping-inside-playbook/15506/3 "2014-06-19T16:50:11Z")

</div>

no apparently I’ve still got this wrong

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [June 19, 2014, 9:27pm UTC](https://forum.ansible.com/t/ping-inside-playbook/15506/4 "2014-06-19T21:27:04Z")

</div>

I’ve seen some interesting variations of:

- local\_action: shell ssh …

For those kinds of tests with keys, feeding it lots of SSH options.

Be careful to launch a command like “echo” and not something interactive.
