Ansible execute script with user a password in execution time

Hi all,

I am trying to figure out how to create a playbook that can pass a user and password in execution time, let me explain better.

The script I will execute require two parameters, then in the middle of the execution it requests for a user and password to continue, the issue I am facing is in this part, I do not how to pass this user and password to the script as it does not request them like parameters.

I cannot modify the script, and the user and password are required to alter a database.

Now I am executing the script with shell module like below:

shell: bash script.sh type 1

But I do not know how to provide the user and password to the script when it asks for that.

Does someone have an idea how can I achieve this ?

Hi @Cristian-Gomez-Arand

You could try using something like expect to feed responses to interactive scripts. You may also need to get ansible to install it on the target host(s) if it isn’t already there.

You’ll need to test this locally first by creating a shell script that asks the same questions and developing an expect script to drive it. When you have that working, then patch it into the plays.

Before you ask, no I don’t have a working example :slight_smile: