Make ansible reprompt for password if `--ask-vault-pass` entered password does not decrypt?

419 Views Asked by At

When I use --ask-vault-pass and enter the password correctly. The playbook works. When I use --ask-vault-pass and enter the password incorrectly. The error msg: Decryption failed (no vault secrets were found that could decrypt) and the playbook ends. This is expected.

I run my playbook through other scripts. I need Ansible to continue to prompt for the password if it did not decrypt correctly.

How can I do this?

Be aware: I refuse to use any method / work around that requires my script outputting the password to a file and having ansible use, no matter how "quick" it is.

EDIT:

I should detail how I use ansible vault. I have a settings.yaml file that I put the vault passwords in like this

general_password: !vault |                                                                                                                                                                                                                                            
          $ANSIBLE_VAULT;1.1;AES256                                                                                                                                                                                                                                   
          66636431343633646639343661353330326634336565653430326662303039643634303564316132                                                                                                                                                                            
          3137363234316532656438373332303861353734393430340a313133666231616163313734323536                                                                                                                                                                            
          62313237323338366361613465303461613534373439333336306130316531363836323137376632                                                                                                                                                                            
          6335303031343732300a343636366463903456726438633864353038333737353838303432346264                                                                                                                                                                            
          3539                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                      
that_password: !vault |                                                                                                                                                                                                                                           
          $ANSIBLE_VAULT;1.1;AES256                                                                                                                                                                                                                                   
          32636131346662626266363634333035653334336436616236316264663866373564326662353330                                                                                                                                                                            
          6464353632323662343332633264636135656132303832640a326562313738373562363632643364                                                                                                                                                                            
          37356438623537393139628394051631366163346233373830373965313437336632613366323332                                                                                                                                                                            
          6237383135316238660a363366336431353438626234303066623233633163346661623162303163                                                                                                                                                                            
          3238                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                      
this_password: !vault |                                                                                                                                                                                                                                           
          $ANSIBLE_VAULT;1.1;AES256                                                                                                                                                                                                                                   
          33363362313163663864323364356661323937313962393532383235316234656230306230366235                                                                                                                                                                            
          3734323731323135383737376435336138333833376263350a356432633634313531633533363736                                                                                                                                                                            
          37376466346437383438353031353063623464356264663766393632396364656339336164396638                                                                                                                                                                            
          3534393530393939310a343134636235386436383238343033656531396434626463616338643431                                                                                                                                                                            
          64346263633463633635303932393731373863333735373234313336343735386639306665323239                                                                                                                                                                            
          33386161316632373434613132663130643762346133343964396235346466656339666435656330                                                                                                                                                                            
                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                      
other_password: !vault |                                                                                                                                                                                                                                             
          $ANSIBLE_VAULT;1.1;AES256                                                                                                                                                                                                                                   
          33646534383764313930623964643635626239373863383433313031393361333736396364353737                                                                                                                                                                            
          4856386162636236383431643733626264336339666233610a353638316263373862653439663666                                                                                                                                                                            
          36633936353064396135323934373865396635613235646631376435663737663638353132303432                                                                                                                                                                            
                                                                                                                                                                                      

0

There are 0 best solutions below