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

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?

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.