Ansible“错误!正在尝试解密,但未找到保管库秘密”,但我没有解密任何内容

Ric*_*d E 9 python ansible

奇怪且令人沮丧的错误

我正在尝试学习并为 Ansible 创建一个 python 模块。我正在关注此页面:Medium.com 这是本地模块,所以我只想使用./library/module.py.

代码:

剧本

---
- hosts: localhost    # I've used 127.0.0.1 here also
  connection: local

  vars:
    - Test: "This is a test"

  tasks:
  - name: set result
    set_fact:
      result: "set"

  - name: Test that my hello_world module works
    hello_world:
    register: result

  - debug: var=result
...
Run Code Online (Sandbox Code Playgroud)

该模块是一个简单的 python 脚本,用于打印“Hello World”。它是./library/hello_world.py

模块

#!/usr/bin/python

from ansible.module_utils.basic import *

def main():
    module = AnsibleModule(argument_spec={})
    theReturnValue = {"hello": "world"}
    module.exit_json(changed=False, meta=theReturnValue)

if __name__ == '__main__':
    main()
Run Code Online (Sandbox Code Playgroud)

我的 ansible.config

[defaults]
inventory = ./inventory
roles_path = ./roles
library = ./library
filter_plugins = ./plugins/filter
lookup_plugins = ./plugins/lookup
callback_whitelist = profile_tasks,timer
log_path = ./ansible.log
gathering = smart
fact_caching = jsonfile
fact_caching_connection = /tmp/server_configurations/Facts/
fact_caching_timeout = 86400
host_key_checking = True
timeout=60

[inventory]
enable_plugins = host_list, ini, script, yaml, auto

[ssh_connection]
pipelining=True
control_path = %(directory)s/ssh-%%h-%%p-%%r
Run Code Online (Sandbox Code Playgroud)

我的问题

当我没有打电话解锁任何东西时,为什么我的剧本会出现保险库错误?我从头开始创建了另一个剧本,看看是否存在复制错误。没有,并且得到了同样的错误。

错误

ansible@VirtualBox:/media/ubuntu20$ ansible-playbook module_test.yml --connection="local 127.0.0.1" -vv
ansible-playbook 2.9.6
  config file = /media/ubuntu20/ansible.cfg
  configured module search path = ['/media/ubuntu20/library']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.8.2 (default, Jul 16 2020, 14:00:26) [GCC 9.3.0]
Using /media/ubuntu20/ansible.cfg as config file

PLAYBOOK: module_test.yml **********************************************************************************************************************************************************
1 plays in module_test.yml
PLAY [localhost] *******************************************************************************************************************************************************************
ERROR! Attempting to decrypt but no vault secrets found
Run Code Online (Sandbox Code Playgroud)

这个错误很令人困惑,因为我没有调用任何保险库,也没有使用任何库存。我手写了剧本,以防我复制了我不想要的任何内容。
我使用了各种“本地”设置来强制本地化,并且没有错误的变化。即使在-vvvv即使我只是出现相同的错误行,

如果这是模块错误那么为什么会显示保管库错误?

(我的 ./inventory/group_vars 中确实有保险库,但我不使用它们)我对此感到头疼。

Ric*_*d E 3

好吧,问题是我库存中的金库。即使我没有直接请求这些保管库,Ansible 也会访问这些保管库。

所以当我添加--vault-pass "<key path"剧本时就运行了。

ansible-playbook module_test.yml --connection="local 127.0.0.1" --vault-pass "/home/ansible/.ssh/ansible_vault_key" -vv
Run Code Online (Sandbox Code Playgroud)

剧本输出的最后一部分

task path: /media/ubuntu20/module_test.yml:15
Thursday 08 October 2020  14:20:22 +0200 (0:00:00.142)       0:00:03.013 ****** 
ok: [localhost] => {"changed": false, "meta": {"hello": "world"}}

TASK [debug] ***********************************************************************************************************************************************************************
task path: /media/ubuntu20/module_test.yml:19
Thursday 08 October 2020  14:20:23 +0200 (0:00:00.966)       0:00:03.979 ****** 
ok: [localhost] => {
    "result": {
        "changed": false,
        "failed": false,
        "meta": {
            "hello": "world"
        }
    }
}
META: ran handlers
META: ran handlers

PLAY RECAP *************************************************************************************************************************************************************************
localhost                  : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Run Code Online (Sandbox Code Playgroud)