Merge "Fix bug trying to decrypt a plaintext file"

This commit is contained in:
Zuul 2022-10-13 21:38:14 +00:00 committed by Gerrit Code Review
commit 18ff3195fc
2 changed files with 11 additions and 0 deletions

View File

@ -76,6 +76,12 @@ def vault_encrypt(module, file_path):
def vault_decrypt(module, file_path):
"""Decrypt a file using Ansible vault"""
# Return immediately if file not encrypted
with open(file_path, 'r') as f:
if not f.readline()[:15] == "$ANSIBLE_VAULT;":
return
password_path = create_vault_password_file(module)
try:
cmd = ["ansible-vault", "decrypt",

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes an error when generating passwords.yml if an unencrypted file exists
but a password has been supplied.