Fix bug trying to decrypt a plaintext file

Story: 2010315
Task: 46382
Change-Id: I840a56339c826d05da663f8cc8eb0623ad12c468
This commit is contained in:
Alex-Welsh 2022-09-22 14:16:27 +01:00
parent 608951fcce
commit c81d9e8b2c
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.