I just recently started to use Ansible, and am trying to deploy a configuration file that contains a secret key and email (for credentials to use with an API). I encrypted them with ansible-vault encrypt_string ...
, and added them to playbook:
- name: generate dehydrated dns-hook config file
template:
src: etc/dehydrated/dns-hook.sh.j2
dest: /etc/dehydrated/dns-hook.sh.j2
vars:
token: !vault |
$ANSIBLE_VAULT;1.2;AES256;dns-hook
66326635666264386238316238373135626233393437633937626534623931636365336231363462
6131333637663337363162653561393962626661313762300a383633303136633564346366383935
65333265306162386564363937636531346265633635656536646533393961343935313161643262
6132336430373235380a313364323438393765613131356535373862306337306434653237316566
34333965356663626231626533656661663364313737663036343161663638373836366235643730
3965323463643231666361356330343663653536306634646438
email: !vault |
$ANSIBLE_VAULT;1.2;AES256;dns-hook
64336666396139636636386536373531343133303964646631346135633033356162626562333561
3338336534333236613330336532353861393265613766380a376632616665366463313237656166
30633135303431336138303535343962663965363536616139393631626534353432313466633064
3466363063666663360a343233376333643931323738356435643930623765306537313437356638
3332396164356236663133613432313063373130653632323432643230646237366
However, whenever I run the playbook, I get the following error:
TASK [generate dehydrated dns-hook config file] *****************************************************
[WARNING]: There was a vault format error: Vault format unhexlify error: Odd-length string
fatal: [sherlock.server.com]: FAILED! => {"changed": false, "msg": "AnsibleVaultFormatError: Vault format unhexlify error: Odd-length string"}
The only thing I can find about this error is that I might have newlines that end in \r\n
instead of just \n
, but I've verified that is not the case. Everything else I've seen online seems to imply that this format should work, but I'm unable to get it to run successfully.