I've created a YAML parser in Python to decrypt values using yaml tags.
password: !decrypt LS0tLS1CRUdJ...TiBQRS0tCg==
In my parser script, I can add a custom constructor to decrypt the values.
def get_loader():
loader = yaml.SafeLoader
loader.add_constructor("!decrypt", decrypt_constructor)
return loader
data = yaml.load(open(file, "rb"), Loader=get_loader())
When parsing the YAML file using Ansible, I get the following error:
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.
could not determine a constructor for the tag '!decrypt'
How can I add a constructor to the YAML parser that is used by Ansible? I've seen these tags before, like !vault and !unsafe.