【问题标题】:Error running playbook with encrypted group_vars使用加密的 group_vars 运行 playbook 时出错
【发布时间】:2019-05-28 09:30:35
【问题描述】:

我正在尝试运行带有已使用 ansible-vault 加密的文件的剧本。但是,我收到以下错误:

ERROR! Syntax Error while loading YAML.
  could not find expected ':'

The error appears to have been in 'inventories/group_vars/main_server': line 41, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

保管库文件内容:

me@server:ansible$ cat inventories/group_vars/main_server
$ANSIBLE_VAULT;1.1;AES256
...

我正在运行的命令:

ansible-playbook -i inventories/group_vars/main_server --extra-vars "target=my_target" playbook.yml --ask-become-pass --ask-pass --vault-password-file vault_pwd.txt

vault_pwd.txt 填充了所需的密码。在开发剧本时,我一直在加密/解密。比如带有加密命令的shell脚本:

ansible-vault encrypt inventories/group_vars/main_server --vault-password-file vault_pwd.txt

编辑#1

Ansible 版本:

me@server:ansible$ ansible --version
ansible 2.7.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/me/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 12 2018, 14:36:49) [GCC 5.4.0 20160609]

【问题讨论】:

  • 错误可能源于受保管内容中的 YAML 语法问题。您需要向我们展示保管文件的未加密内容才能调试此问题。
  • 谢谢!我会在这里看看。我没有考虑过这个。
  • 我使用“=”在一个位置分配一个值,而不是一个冒号。另一个是缺少双引号的 IP。如果您指定答案,我会接受。
  • 请确认:您提供的库存文件 VAULTED(加密)?似乎不支持该特定用例:github.com/ansible/ansible/issues/10408
  • 很高兴为您提供帮助。给你!

标签: ansible ansible-2.x


【解决方案1】:

您看到的错误...

错误!加载 YAML 时出现语法错误。 找不到预期的“:”

错误似乎出现在“inventories/group_vars/main_server”中:第 41 行第 1 列,但可能 根据确切的语法问题,位于文件中的其他位置。

...是 YAML 语法错误。 Ansible 可能在抱怨未加密内容中的实际语法错误(如果幸运的话,错误消息中引用的行实际上就是有错误的行)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多