-1

I am looking to automate an interactive install process with ansible. This install does not have a silent install option or does not take command line arguments for the interactive questions. The question involve setting a folder location, making sure folder location is right etc for which answers might be default or custom. I looked into the expect module of ansible but seems like it does not solve my purpose.

- expect:
command: passwd username
responses:
  (?i)password: "MySekretPa$$word"

I don't need the command but it's required. Instead I am looking for something that could regex Are you sure you want to continue [y|n]? [n]: for which I want to send the default out By sending return or typing n as a response and for example Backup directory [/tmp] for which the response would be Carriage return.

ash
  • 781
  • 1
  • 9
  • 20

2 Answers2

1

I don't need the command but it's required. Instead I am looking for something that could regex Are you sure you want to continue [y|n]? [n]:

The module requires a command because you have to run something to get any output.

You obviously do have a command in mind, because you've run it manually and seen the output it produces. That's what you should be plugging into the module.

Alternatively, you can write a pexpect script yourself and use the command or shell modules to run it.

Xiong Chiamiov
  • 13,076
  • 9
  • 63
  • 101
0

I've figured out a way that works for me. I piped in the arguments to the shell script which when run manually needs the answers. Like ./shell.sh <<< 'answer1\nanswer2\n' which works perfectly for me. This I have added to the task.

ash
  • 781
  • 1
  • 9
  • 20