Reputation: 1679
I'm trying to get an ansible script to prompt the user. I have the following script:
- name: Generate a new SSH Key
shell: ssh-keygen -t rsa -b 4096 -C {{email_address}}
When I run from command line, it ask for a passphrase and file location. When I run from the ansible, it uses the default values. How do I get it to pause, so that it asks the user.
Upvotes: 0
Views: 688
Reputation: 52393
You have a few options:
Write an Expect script, copy it to the destination machine and execute it
or
Use Ansible's Expect module
- expect:
command: ssh-keygen -t rsa -b 4096 -C {{email_address}}
responses:
'Enter file in which .*': '/home/gibson/.ssh/id_rsa'
or
Specify non-interactive ssl-keygen
- shell: ssh-keygen -f myfile.rsa -t rsa -b 4096 -C {{email_address}} -N ''
or
Use Ansible's vars_prompt to prompt for the value and pass it to the command
vars_prompt:
- name: "key_file_name"
prompt: "Enter file in which to save the key: "
...
...
tasks:
- shell: ssh-keygen -f {{key_file_name}} -t rsa -b 4096 -C {{email_address}} -N ''
Upvotes: 3