Ansible doesnt allows multiple promots at the same time "y\ny\n"

28 views
Skip to first unread message

NouraD

unread,
Apr 3, 2017, 4:40:33 PM4/3/17
to Ansible Project
Hi ,

ansible 2.1.4.0

 

I am trying to use ansible module to execute a sciprt < custom work flow> . I have notices that ansible allows me to enter only one prompt  'y'  from the question generated out of the custom script.

 

I tried to use 'command' or 'expect' modules, but also didn't work as it expect pexpect modules .

 

I moved my command from a module to a bash file and asked ansible to run the file but also same issue. < not allowing more than one promot at a time>

 

any Idea how to fix this issue? what module or expression i should be using?

 

here is my task :

------------------------------------------------------------------

 

[root@a9]# cat  /tasks/main.yaml

---

- name: place generated config file into active VM

  template: src=config-template dest=/root/config-file owner=root group=root mode=0644

 

- name: bash file

  template: src=run.bash dest=/root/run.bash owner=root group=root mode=0777

 

- name: Run

  shell: /root/run.bash | tee -a /root/template.cfg

  register: myoutput

 

- name: variableoutput

  debug: msg="{{ myoutput }}"


-------------------------------------------------------------------

 

[root@a]# cat  /templates/run.bash

#!/bin/bash

/bin/printf "y\ny\n" | /opt/config/bin/MyScript -f /root/config-file


 ----------------------------------------------------------------------------

 

 

Task is stucked here with no action .


Thank you!

Noura


J Hawkesworth

unread,
Apr 4, 2017, 1:53:18 AM4/4/17
to Ansible Project
Have a look for vars_prompt in the ansible documentation. This is probably the best way to make interactive scripts with ansible.

Jon

NouraD

unread,
Apr 4, 2017, 9:36:18 AM4/4/17
to Ansible Project
I tried adding var_prompts on instantiate playbook, but same result . couldn't use it as default answer for any prompts ..

- hosts: "OAM"

  vars_prompt:
    - default: "y"

what should i add to let Ansible push "Y' to any prompt from thr script above?
Reply all
Reply to author
Forward
0 new messages