cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
694
Views
0
Helpful
2
Replies
O_H
Beginner
Beginner

Generate RSA Keys & Certificates using Ansible

Hello,

I'm trying to generate new RSA keys & Certificates on Cisco switches/routers using Ansible...
The process should be as below. I'm aware of how to push commands from Ansible. But the problem with this RSA key generate command that it can take a long time to finish, and that further commands are dependent on this. 

 

My problem is that i want to execute the first command. then wait to see ([OK]) in the output before proceeding with next commands. But i couldn't find a way to parse the output of the 1st command in any module i have seen. Any ideas?

router(config)# crypto key generate rsa label RSA-Key modulus 4096
The name for the keys will be: RSA-Key

% The key modulus size is 4096 bits
% Generating 4096 bit RSA keys, keys will be non-exportable...
[OK] (elapsed time was 100 seconds)

router(config)#crypto pki trustpoint Self-Signed-Certificate
router(ca-trustpoint)#enrollment selfsigned
router(ca-trustpoint)#subject-name O=GeneratedCertificate,CN=Self-Signed-Certificate
router(ca-trustpoint)#hash sha256
router(ca-trustpoint)#rsakeypair RSA-Key

router(config)#crypto pki enroll Self-Signed-Certificate
% Include the router serial number in the subject name? [yes/no]: no
% Include an IP address in the subject name? [no]: no
Generate Self Signed Router Certificate? [yes/no]: yes

Router Self Signed Certificate successfully created

@Ansible

 

2 REPLIES 2
balaji.bandi
VIP Guru

I'm aware of how to push commands from Ansible. But the problem with this RSA key generate command that it can take a long time to finish, and that further commands are dependent on this.