2

I'm aware that a command such as something -y will force a yes answer on any response back from the terminal, but I'm having problems with getting Ansible to automate the process of configuration. The module in question has defaults (a [no]) and the provisioning process hangs as I can't configure it to automatically select default answers.

Is there a way to run a command have the terminal automatically select defaults, as you can do with the -y flag?

2 Answers2

2

If you're looking to interact via a script with a program that doesn't allow you to select the correct options via command-line switches or an answers file for non-interactive operation, but only supports user interaction, you may want to take a look at expect

If you only need to answer a single question, then yes or yes <answer> is your friend.

HBruijn
  • 72,524
  • 21
  • 127
  • 192
0

You can probably do this with a little creative crafting of the yes command.

yes | script.sh or yes | command or if you wanted a "n", try yes n | command

ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • Thanks! I did this solution with a little crafting with Ansible. Since the default was no, I piped it in with the Ansible `shell` command. I think `expect` is a better solution though. –  Oct 23 '14 at 23:05
  • `shell: '"no" | pecl install mongo'` was what finally got it. –  Oct 23 '14 at 23:07