Issues with expect

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?

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 ....

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”

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:
https://pexpect.readthedocs.org/en/stable/api/pexpect.html#run-function
https://docs.python.org/2/library/re.html#regular-expression-syntax