带有加密 group_vars 的错误 运行 剧本

Error running playbook with encrypted group_vars

我正在尝试 运行 一个带有已使用 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
...

命令我是 运行ning:

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 填充了所需的密码。在开发我的剧本时,我一直 encrypting/decrypting。例如,带有加密命令的 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]

您看到的错误...

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.

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