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


On Mon, Mar 13, 2017 at 4:33 PM, <[email protected]> wrote:

>
> Using version - ansible 2.2.0.0
>
> On Sunday, March 12, 2017 at 8:23:09 PM UTC, Peter Sprygada wrote:
>>
>> which version of ansible are you running?
>>
>> On Fri, Mar 10, 2017 at 9:29 AM, <[email protected]> wrote:
>>
>>> 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://[email protected]/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://[email protected]/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
>>>
>>> --
>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/ansible-project/fc55eed2-32d3-4b56-934a-055a64004a5f%
>>> 40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/fc55eed2-32d3-4b56-934a-055a64004a5f%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/645bec83-b5b1-45be-9dc7-73c918ea7184%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/645bec83-b5b1-45be-9dc7-73c918ea7184%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEkdrMiBNzAkg-1Ds57KjYOHEq66tmOAP7apVRphOhOO5buxMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to