Handling prompts and drop-downs via ansible 2.9

Hi everyone,

Am trying to install jenkins-x version 2.0.785 via ansible 2.9.9.

How do I handle the prompts like “Please enter the name you wish to use with git:” that I get while installing jenkins-x? I get the prompt even though “–git-username=automation” is already passed in the JX install command. I tried with both expect and shell module in ansible.

There are also yes/no prompts to be handled that I will get further.

Regards,
Nishant Passari

Hello,

if you aren't able to automate with silent install, use the expect module.

Luca

Already tried with expect and shell module.


- name: Handling multiple prompts
expect:
command: jx install --git-provider-kind bitbucketserver --git-provider-url http://xyz-abc-git.net.local --git-username automation --default-environment-prefix Testproject --git-api-token MzI1ODg1NjA1NTk4OqjiP9N3lr4iHt9L5rofdaWMqsW --on-premise --external-ip {{ hostvars[groups["kubemaster"][0]]["ip"] }} --verbose --static-jenkins=true --provider=openshift
responses:
Question:
- Please enter the name you wish to use with git: automation
timeout: 60


- name: Handling prompts
expect:
command: jx install --git-provider-kind bitbucketserver --git-provider-url http://abc-xyz-git.net.local --git-username automation --default-environment-prefix Testproject --git-api-token MzI1ODg1NjA1NTk4OqjiP9N3lr4iHt9L5rofdaWMqsW --on-premise --external-ip {{ hostvars[groups["kubemaster"][0]]["ip"] }} --verbose --static-jenkins=true --provider=openshift
responses:
Please enter the name you wish to use with git: "automation"