Trying to distribute Desktop Central agent to linux servers - prompt for 'reinstall' is teasing me, trying with 'expect'

128 views
Skip to first unread message

Kenneth Fribert

unread,
Apr 26, 2019, 6:20:50 AM4/26/19
to Ansible Project
Hi All

I've made a small playbook, that installs pip, and pexpect on our target servers, as I was thinking I needed to use the expect in the playbook.

So the yaml looks like this:

  - name: Installing Desktop Central Agent
    expect:
      command: "/root/DesktopCentral_LinuxAgent.bin"
      responses:
        "Do you want to uninstall the existing agent and re-install this agent? (y/n)" : n

So if it asks (because the playbook is rerun) it should just say "n"

But it fails with this message:

fatal: [servername]: FAILED! => {"changed": true, "cmd": "/root/DesktopCentral_LinuxAgent.bin", "delta": "0:00:30.117165", "end": "2019-04-26 12:06:47.724526", "msg": "command exceeded timeout", "rc": null, "start": "2019-04-26 12:06:17.607361", "stdout": "ServerInfo File Exists. Proceeding with Installation.\r\nAgent Already Installed.\r\nDo you want to uninstall the existing agent and re-install this agent? (y/n) : ", "stdout_lines": ["ServerInfo File Exists. Proceeding with Installation.", "Agent Already Installed.", "Do you want to uninstall the existing agent and re-install this agent? (y/n) : "]}

So what did I misunderstand?

Also, I'm unsure if the command will fail on systems not prompting for anything?

Matt Martz

unread,
Apr 26, 2019, 9:46:53 AM4/26/19
to ansible...@googlegroups.com
The expected string to match is a regex string.  As such, things like `?` have special meaning.  You can give partial string matches to make it easier, so that you don't have to escape things if that will work for you.

--
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/3ae658da-4093-472e-82c3-a5de21bc6383%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