带有“奇数长度字符串"的 Ansible 保险库错误 [英] Ansible-vault errors with "Odd-length string"

查看:30
本文介绍了带有“奇数长度字符串"的 Ansible 保险库错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 Ansible 1.8.2.我在另一个系统上创建了一个保管库文件.在该系统上它可以正常工作.但是,当我在本地系统上运行它时,出现以下错误:

I'm running Ansible 1.8.2. I have a vaulted file created on another system. On that system it works without any problems. However, when I run it on my local system I get the following error:

$» ansible-vault --debug view vars/vaulted_vars.yml
Vault password:
Traceback (most recent call last):
  File "/usr/bin/ansible-vault", line 225, in main
    fn(args, options, parser)
  File "/usr/bin/ansible-vault", line 172, in execute_view
    this_editor.view_file()
  File "/usr/lib/python2.7/site-packages/ansible/utils/vault.py", line 280, in view_file
    dec_data = this_vault.decrypt(tmpdata)
  File "/usr/lib/python2.7/site-packages/ansible/utils/vault.py", line 136, in decrypt
    data = this_cipher.decrypt(data, self.password)
  File "/usr/lib/python2.7/site-packages/ansible/utils/vault.py", line 545, in decrypt
    data = unhexlify(data)
TypeError: Odd-length string

ERROR: Odd-length string

我尝试手动输入密码或复制粘贴密码,但错误仍然发生.

I tried to manually type in the password or copy-pasting it, but the error still happens.

这里发生了什么以及如何修复此错误?

What is going on here and how to fix this error?

推荐答案

原来这个错误是因为从 Ansible 1.8.2 开始,它需要一个非常特定的行尾编码来存储文件.

Turns out this error is because as of Ansible 1.8.2 it requires a very specific line-end encoding for the vaulted files.

当我拥有这种类型的文件时,它会失败:

When I had this type of file it would fail:

$» file vaulted_vars.yml
vaulted_vars.yml: ASCII text, with CRLF line terminators

然而,一旦我把它改成这个,它就开始工作了:

However, once I changed it to this, it started working:

$» file vaulted_vars.yml
vaulted_vars.yml: ASCII text

这整个问题的发生是因为我的 git 客户端正在更改换行符.具体见这篇文章:https://help.github.com/articles/处理行尾/

This whole problem happened because my git client was changing linefeed characters. See this article for specifics: https://help.github.com/articles/dealing-with-line-endings/

这篇关于带有“奇数长度字符串"的 Ansible 保险库错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆