Ansible Expect module not responding to questions

66 views
Skip to first unread message

Diptajeet Khan

unread,
Dec 2, 2018, 11:57:03 AM12/2/18
to Ansible Project
Hi,

Having some trouble in responding to questions of expect module in my code. Any help appreciated... Below is the code & traceback.

BR

Code:

---

- name: "Deploy AAS Platform"

  connection: local

  hosts: all

  vars_prompt:

    - name: "aas_host"

      prompt: "Enter the AAS hostname suffix"

      private: no

      default: "fcidigital.com"

    - name: "aas_port"

      prompt: "Enter the AAS WEB URL port (Defaults to 80)"

      private: no

      default: "80"

    - name: "aas_smtp"

      prompt: "Enter the AAS SMTP server (Defaults to cas-yt31.exch.g01.local)"

      private: no

      default: "cas-yt31.exch.g01.local"

    - name: "aas_ip"

      prompt: "Enter the AAS Platform server IP address"

      private: no

      default: ""

    - name: "aas_password"

      prompt: "Enter the AAS Platform superuser password (Hint : Enter password from 8 to 32 alphanumeric characters)"

      private: yes

    - name: "aas_sysadm"

      prompt: "Enter the mail address of System administrator"

      private: no

      default: "x...@gmail.com"

    - name: "aas_lang"

      prompt: "Enter the language of DADock Portal for superuser [ja/en] (Hint: Input [ja] for Japanese or [en] for English language.)"

      private: no

      default: "en"

     

  tasks:       

    - name: "Configure AAS Platform - ETA : 30 minutes"

      expect:

        command: /root/dadock-installer/assets/bin/configure.sh

        responses:

          (?i)Enter the hostname suffix \>: "{{ aas_host }}"

          (?i)Enter the port number \>: "{{ aas_port }}"

          (?i)Enter the SMTP server \>: "{{ aas_smtp }}"

          (?i)Enter the IPv4 address \>: "{{ aas_ip }}"

          (?i)Enter superuser password \(8\-32 characters\) \>: "{{ aas_password }}"

          (?i)Retype superuser password \>: "{{ aas_password }}"

          (?i)Enter the mail address \>: "{{ aas_sysadm }}"

          (?i)Enter the language for superuser \>: "{{ aas_lang }}"

          (?i)Enter y to begin installation \(press \[Ctrl\+C\] to cancel\) >: "y"

        timeout: 1800

      register: configure_result

 

    - debug: msg={{ configure_result.stdout.split('\n') }}

       

================================

Traceback:

 

fatal: [localhost]: FAILED! => {

    "changed": true,

    "cmd": "/root/dadock-installer/assets/bin/configure.sh",

    "delta": "0:30:00.124825",

    "end": "2018-12-02 21:56:00.354798",

    "invocation": {

        "module_args": {

            "chdir": null,

            "command": "/root/dadock-installer/assets/bin/configure.sh",

            "creates": null,

            "echo": false,

            "removes": null,

            "responses": {

                "(?i)Enter superuser password \\(8\\-32 characters\\) \\>": " test123",

                "(?i)Enter the IPv4 address \\>": "10.34.156.138",

                "(?i)Enter the SMTP server \\>": "cas-yt31.exch.g01.local",

                "(?i)Enter the hostname suffix \\>": "fcidigital.com",

                "(?i)Enter the language for superuser \\>": "en",

                "(?i)Enter the mail address \\>": "x...@gmail.com",

                "(?i)Enter the port number \\>": "80",

                "(?i)Enter y to begin installation \\(press \\[Ctrl\\+C\\] to cancel\\) >": "y",

                "(?i)Retype superuser password \\>": "test123"

            },

            "timeout": 1800

        }

    },

    "msg": "command exceeded timeout",

    "rc": null,

    "start": "2018-12-02 21:26:00.229973",

    "stdout": "",

    "stdout_lines": []

}

Kai Stian Olstad

unread,
Dec 3, 2018, 1:56:07 PM12/3/18
to ansible...@googlegroups.com
On Sunday, 2 December 2018 17:57:03 CET Diptajeet Khan wrote:
> "msg": "command exceeded timeout",
>
> "rc": null,
>
> "start": "2018-12-02 21:26:00.229973",
>
> "stdout": "",
>
> "stdout_lines": []
>
> }

Your stdout is empty, that means your program have not prompted any text that the expect module could response to, hence the timeout.


--
Kai Stian Olstad


Diptajeet Khan

unread,
Dec 3, 2018, 6:02:58 PM12/3/18
to ansible...@googlegroups.com
Thanks Kai!
Yes was wondering about that but unfortunately the script '/root/dadock-installer/assets/bin/configure.sh' interact when ran manually.

BR



--
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/5796313.L6qPfNmxL3%40x1.
For more options, visit https://groups.google.com/d/optout.

Kai Stian Olstad

unread,
Dec 4, 2018, 2:47:06 AM12/4/18
to ansible...@googlegroups.com
On 04.12.2018 00:02, Diptajeet Khan wrote:
> Thanks Kai!
> Yes was wondering about that but unfortunately the script '
> /root/dadock-installer/assets/bin/configure.sh' interact when ran
> manually.

Might be that the script detect it's not running interactively.
Since it's a shell script it should be possible to read the code and
figure out what it does.

--
Kai Stian Olstad

Diptajeet Khan

unread,
Dec 4, 2018, 2:51:40 AM12/4/18
to ansible...@googlegroups.com
Hi Kai,

I got the same command working via 'shell' module & interact via - spawn/expect/send.

Though I am still wondering why pexpect doesn't do the same when I can see that the script does get triggered from process logs.

BR

--
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.
Reply all
Reply to author
Forward
0 new messages