For example,
show interface status
show version
show ip route
how can a module be written in Ansible to prompt user for the show command to type in when running a playbook. If entered one command (show interface status) and matched, print the output and ignore the rest other commands. If no match found, print default msg : “command not found” or something like that.
I am noob to Ansible.
Thanks for your help!
system
(system)
August 5, 2021, 2:50pm
2
I would use vars_prompt and feed that data to the module or you can
use the pause action
(https://docs.ansible.com/ansible-core/2.11/collections/ansible/builtin/pause_module.html )
But a normal module cannot prompt the user, they are designed to be
executed on the remote.
rolandm
(Roland Müller)
August 5, 2021, 9:47pm
3
If you just want to execute task by task and press OK for continuing you could use the step mode by adding --step to the ansible-playbook command.
This way ansible-playbook will ask before every task to execute it (=y) skip it (=n) or continue without stepping (=c).
Perform task: configure ssh (y/n/c):
https://docs.ansible.com/ansible/2.4/playbooks_startnstep.html#step
$ ansible-playbook playbook.yml --step
However, - as Brian already pointed out - providing additional information during execution of the playbook is not supported.