Difference between revisions of "Using SSH Password with Ansible"

From Knowledge Center
Jump to: navigation, search
(Created page with " Using the ping module: <pre> $ ansible -i inventory.ini nodes -m ping -u root --ask-pass SSH password: n1 | SUCCESS => { "changed": false, "ping": "pong" } </pre>...")
 
(No difference)

Latest revision as of 01:09, 14 May 2019

Using the ping module:

$ ansible -i inventory.ini nodes  -m ping -u root --ask-pass
SSH password:
n1 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

Using a playbook:

$ cat test.yml
---
- hosts: all
  tasks:
    - shell: uname -a
      register: uname

    - debug: msg="{{ uname.stdout }}"

then:

$ ansible-playbook -i inventory.ini -u root --ask-pass test.yml
SSH password:

PLAY [all] *************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************************************************************
ok: [n1]

TASK [shell] ***********************************************************************************************************************************************************************************************
changed: [n1]

TASK [debug] ***********************************************************************************************************************************************************************************************
ok: [n1] => {
    "msg": "Linux n1.ruan.dev 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux"
}

PLAY RECAP *************************************************************************************************************************************************************************************************
n1                         : ok=3    changed=1    unreachable=0    failed=0