# Raw module and interactive commands

**URL:** <https://forum.ansible.com/t/raw-module-and-interactive-commands/19913>\
**Category:** Ansible Project\
**Created:** [December 1, 2015, 10:26pm UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913 "2015-12-01T22:26:56Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [December 1, 2015, 10:26pm UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/1 "2015-12-01T22:26:56Z")

</div>

Is it possible to use the raw module to interactively enter text? For example, I’m trying to manage a switch and one of the commands ask a yes/no question. Is it possible to enter a “y” right after invoking the command? I tried to create a playlist using raw: “save primary\ny” but that didn’t work.

James

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 2, 2015, 12:53am UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/2 "2015-12-02T00:53:44Z")

</div>

No, its completely batch, you can try the expect module for interactive prompts.

---

<div class="post-metadata">

**Author:** ![psprygada](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@psprygada](https://forum.ansible.com/u/psprygada)\
**Post date:** [December 2, 2015, 3:23am UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/3 "2015-12-02T03:23:59Z")

</div>

What switch are you trying to send commands to?

We have started to incorporate network device support into the module\_utils for connecting to interactive devices over ssh with initial support for IOS based devices. See here for the IOS shared module support ([https://github.com/ansible/ansible/pull/13358/files](https://github.com/ansible/ansible/pull/13358/files)) and here ([https://github.com/ansible/ansible-modules-core/pull/2587/files](https://github.com/ansible/ansible-modules-core/pull/2587/files)) for an example module

---

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [December 2, 2015, 9:53pm UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/4 "2015-12-02T21:53:28Z")

</div>

Extreme Networks’ EXOS. It’s Linux based but doesn’t have Python or other languages except one that I can’t remember it’s heritage (TCL maybe?). I think the prompt is a heavily modified BusyBox or something.

I’m not sure how I would go about testing those 2 modules. I could try them if you think they might work. I can use the raw module to send commands and get back results, I just can’t find any way around some of the interactive prompts.

I believe Extreme is working on adding Ansible support to their OS, but my switches won’t can’t be upgraded to any newer versions so I can’t get those updates.

---

<div class="post-metadata">

**Author:** ![Tim\_Fletcher](https://avatars.discourse-cdn.com/v4/letter/t/b5e925/32.png) [@Tim\_Fletcher](https://forum.ansible.com/u/Tim_Fletcher)\
**Post date:** [December 3, 2015, 12:02am UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/5 "2015-12-03T00:02:28Z")

</div>

That's great news, especially as I have written an ugly bit of bash this  
week to bulk unset and reset the correct ntp servers on all out Cisco  
switches...

---

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [December 10, 2015, 11:01pm UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/6 "2015-12-10T23:01:05Z")

</div>

Is there a tutorial anywhere about how to get started using the expect module? I’ve installed pexpect but when I try to use it in a playbook it fails with this message:

ERROR: expect is not a legal parameter in an Ansible task or handler

Based on what I’ve found (I could only find 2-3 examples, there doesn’t seem to be any documentation other than [https://docs.ansible.com/ansible/expect\_module.html](https://docs.ansible.com/ansible/expect_module.html), which doesn’t adequately explain how to use it), the playbook should look something like this.

tasks:

- expect:  
command: save primary  
responses:  
Do you want to save configuration to primary.cfg and overwrite it? (y/N): “Y”

Am I missing something? This page says that the extra’s modules is shipped with ansible, is that still accurate? [https://docs.ansible.com/ansible/modules\_extra.html](https://docs.ansible.com/ansible/modules_extra.html)

James

---

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [December 10, 2015, 11:07pm UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/7 "2015-12-10T23:07:38Z")

</div>

On investigation it appears that I do not have the expect module. I thought I installed ansible with pip install ansible, but I earlier tried homebrew but it didn’t work. Maybe something got messed up. I guess I’ll try to figure out how to fix my installation.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [December 10, 2015, 11:30pm UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/8 "2015-12-10T23:30:51Z")

</div>

The Ansible expect module will be shipped with 2.0. The current released version is 1.9.4.

---

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [December 10, 2015, 11:34pm UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/9 "2015-12-10T23:34:33Z")

</div>

I’ve uninstalled and reinstalled version 1.9.4 and it isn’t with it. I downloaded it from github and added “library = /path/to/ansible/modules:/path/to/extras” to the ansible.cfg file, had to fix my command to the following text

- expect:  
command: save primary  
responses:  
Do you want to save configuration to primary.cfg and overwrite it? (y/N): “Y”

but I still get an error. It looks like ansible is still trying to copy a file to the switch. The switches don’t allow files to be copied to them. I’m guessing I can’t use the expect module after all.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 11, 2015, 3:35am UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/10 "2015-12-11T03:35:19Z")

</div>

It still won't work with the switch as it is a module, which NEEDS to  
be copied to the target and then executed via python, raw is the only  
'module' that does not do this, it is really a special case inside  
Ansible and not a real module.

In 2.0 we are adding the scaffolding to deal with switches, we will  
also be adding modules to manage them that take into account the  
quirks they have.

---

<div class="post-metadata">

**Author:** ![theyuseus](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@theyuseus](https://forum.ansible.com/u/theyuseus)\
**Post date:** [December 11, 2015, 9:37pm UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/11 "2015-12-11T21:37:13Z")

</div>

Awesome, thank you for the information.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 11, 2015, 10:14pm UTC](https://forum.ansible.com/t/raw-module-and-interactive-commands/19913/12 "2015-12-11T22:14:46Z")

</div>

In 2.0 we have module\_utils/ssh.py (to be renamed) that is the core of shared code for future modules that will deal with that kind of switch.
