Network Modules - dealing with Interactive prompts

73 views
Skip to first unread message

jb79...@gmail.com

unread,
Mar 10, 2017, 9:29:26 AM3/10/17
to Ansible Project
Hello,

What is the best approach to dealing with interactive commands. I am attempting to use ansible to download a software file to a switch using a "copy scp://ad...@1.1.1.1/sw/software_file flash:software_file".

I have attempted to store the response to a variable and send another task with the password if the password prompt is listed in the variable, but ansible hangs on the password prompt.

Is this a correct approach? is there a better method to working with interactive commands?


---

- hosts: arista

  gather_facts: no

  connection: local

  strategy: free

  tasks:

    - name: download software

      ignore_errors: yes

      eos_command:

         host: arista

         username: admin

         password: xyz

         authorize: yes

         commands:

          - copy scp://ad...@1.1.1.1/sw/software_file flash:software_file

      register: test

    - name: password enter

      ignore_errors: yes

      eos_command:

         host: admin

         username: admin

         password: xyz

         ignore_errors: yes

         authorize: yes

         commands:

          - the_password

      when: “’password_prompt’ in test"




thanks.

jb

Peter Sprygada

unread,
Mar 12, 2017, 4:23:09 PM3/12/17
to ansible...@googlegroups.com
which version of ansible are you running?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/fc55eed2-32d3-4b56-934a-055a64004a5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jb79...@gmail.com

unread,
Mar 13, 2017, 4:33:46 PM3/13/17
to Ansible Project

Using version - ansible 2.2.0.0
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Peter Sprygada

unread,
Mar 14, 2017, 10:39:34 AM3/14/17
to ansible...@googlegroups.com
In Ansible 2.2 you can encode the prompt / response in the task as such:

eos_command:
  commands:
    - command: command to run
      prompt: Do you want to continue?
      response: yes


To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/645bec83-b5b1-45be-9dc7-73c918ea7184%40googlegroups.com.

jb79...@gmail.com

unread,
Mar 15, 2017, 5:17:03 AM3/15/17
to Ansible Project
Hi,

I have tried this the playbook runs but the task always times out - assuming it isn't sending the "response". 

Can I confirm that the syntax is correct that I am using for the prompt and response?

The prompt when run directly on the switch is "j...@172.16.136.252's password:" I have tried various combinations of this for a match (password, password:, "password:", password":"

---

- hosts: arista
  gather_facts: no
  connection: local
  strategy: free
  tasks:
    - name: check VLAN
      eos_command:
        host: arista
        username: admin
        password: 12345
        authorize: yes
        commands:
          - command: copy scp://j...@172.16.136.252/somefile flash:somefile
            prompt: j...@172.16.136.252's password":"
            response: 123456





thanks

Reply all
Reply to author
Forward
0 new messages