Issues with expect

249 views
Skip to first unread message

Mark Constant

unread,
Jan 13, 2016, 11:53:22 AM1/13/16
to Ansible Project
I installed ansible 2.0 using pip. I am trying to use the expect command and it is not working. When I try to add
-name: Install Program
 expect:
   command: some command
     responses:

I get ERROR! Syntax Error while loading YAML.

If I take out the -name and do

 -expect:
   command: some command
     responses:

It says -expect is not a valid attribute for a task

Are the extras modules installed when you use pip now? I tried pip install ansible-modules-extras but it said it could not find a version that satisfies the requirements. My python (installed using yum) version is 2.7 and my pexect version was just installed using pip and it above 3.3. When I did yum the expect version looked old.

Also when doing the responses is there much information on how the response should be formatted? In the ansible document I see something like (i?)password. Is there any documentation on what the (i?) means and thing such as do I need to type in the whole question that will be asked or can I do some kind of other matching like if the question starts with? Or can I put (i?) and anything I want and it understands to just answer the question presented?

Brian Coca

unread,
Jan 13, 2016, 12:03:49 PM1/13/16
to Ansible Project
looks like you have a bad indent, this is not an expect issue but a
general parser one, responses should be at same level as command.

as for install, there is no change extras is part of main ansible
install and does not requires separate install yet.

not sure what (i?) is though ....

--
Brian Coca

Mark Constant

unread,
Jan 14, 2016, 1:26:17 PM1/14/16
to Ansible Project
The (I?) is from the example in the documentation. I meant to really put (?I). There really seems to be know documentation on how to properly format the response questions.

- expect:
    command: passwd username
    responses:
      (?i)password: "MySekretPa$$word"

Matt Martz

unread,
Jan 14, 2016, 1:43:01 PM1/14/16
to ansible...@googlegroups.com
Mark,

The response questions can either be statically defined strings or regex.  The (?i) is python regex syntax for for indicating case insensitive comparison.

The underlying library used by the expect module is pexpect.

Further information at:


--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8dc572d3-98ce-4ce7-b5d7-64a94eb2e8fc%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages