0

I'm currently using the following code in ansible:

- shell: /file.rc

File.rc requires user to provide an input(1 or 2) during runtime.

If it's command line argument I can run it like below

- shell: /file.rc 1

But how to provide runtime inputs using shell module in Ansible.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Vin
  • 61
  • 2
  • 8
  • A command-line argument *is* a kind of runtime input. Do you mean it's reading from stdin? Ideally, scripts that unconditionally read from stdin should be fixed to *not do that* -- to take data from the command line or argument list instead. – Charles Duffy Mar 24 '20 at 17:55
  • However, if it *is* stdin that you mean, you might want `- shell: echo 1 | /file.rc` – Charles Duffy Mar 24 '20 at 17:56
  • Yes, I want to give input using standard input. - shell: echo 1| /file.rc this works like command line arguments. – Vin Mar 24 '20 at 18:41
  • No, it does not. `echo 1 | /file.rc` feeds content on stdin, not the command line. Only with `xargs` does stdin get transformed into a command-line argument. – Charles Duffy Mar 24 '20 at 18:44

0 Answers0