I am trying to pass a prompt y in ansible when it executes command.
When i do manually on server it asks for a prompt. 

The issue is for command to run i need to pass the executable /bin/bash 
*command: `source /etc/profile.d/tableau_server.sh && tsm pending-changes 
apply`* for expect command to run  i need to pass /usr/bin/expect . 

My question, how can i pass 2 executable in ansible such that for command 
it uses /bin/bash and for expect prompt it should use /usr/bin/expect and 
the error is because i am using source, what is an alternative i can use?

Update: I dont know why but i am not able to pass --ignore-prompt , It 
gives an error 

    ubuntu@ip-xx-xxx-xx-xx:~$ tsm pending-changes apply --ignore-prompt
    Unrecognized option: --ignore-prompt

Please help me with a solution!

    ubuntu@ip-xx-xxx-xx-xx:~$ tsm pending-changes apply
    This operation will perform a server restart. Are you sure you wish to 
continue?
    (y/n): 

My ansible script:

      shell: |
         source /etc/profile.d/tableau_server.sh && tsm pending-changes 
apply
         expect "This operation will perform a server restart. Are you sure 
you wish to continue?\n(y/n):"
         send "y\n"
         exit 0
      args:
         executable: /usr/bin/expect
          args:
             executable: /bin/bash/expect
          when: inventory_hostname == "xx.xxx.xx.xx"


ERROR:

     changed: [xx.xxx.xxx.xx] => {
        "changed": true,
        "cmd": "source /etc/profile.d/tableau_server.sh && tsm 
pending-changes apply\n expect \"This operation will perform a server 
restart. Are you sure you wish to continue?\\n(y/n):\"\n send \"y\\n\"\n 
exit 0",
        "delta": "0:00:00.034824",
        "end": "2018-08-20 17:29:41.457700",
        "invocation": {
            "module_args": {
                "_raw_params": "source /etc/profile.d/tableau_server.sh && 
tsm pending-changes apply\n expect \"This operation will perform a server 
restart. Are you sure you wish to continue?\\n(y/n):\"\n send \"y\\n\"\n 
exit 0",
                "_uses_shell": true,
                "argv": null,
                "chdir": null,
                "creates": null,
                "executable": "/usr/bin/expect",
                "removes": null,
                "stdin": null,
                "warn": true
            }
        },
        "rc": 0,
        "start": "2018-08-20 17:29:41.422876",
        "stderr": "wrong # args: should be \"source ?-encoding name? 
fileName\"\n    while executing\n\"source /etc/profile.d/tableau_server.sh 
&& tsm pending-changes apply\"",
        "stderr_lines": [
            "wrong # args: should be \"source ?-encoding name? fileName\"",
            "    while executing",
            "\"source /etc/profile.d/tableau_server.sh && tsm 
pending-changes apply\""
        ],
        "stdout": "",
        "stdout_lines": []

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e6d29ce7-7856-41b5-bd01-3a5a83f08fe9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to