【发布时间】:2020-10-08 11:48:52
【问题描述】:
奇怪而令人沮丧的错误
我正在尝试为 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
...
该模块是一个用于打印“Hello World”的简单 Python 脚本。
是./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()
我的 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
我的问题
当我没有调用解锁任何东西时,为什么我的 playbook 出现 Vault 错误? 我从头开始创建了另一个剧本,看看是否有任何复制错误。没有,并且得到了同样的错误。
错误
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
这个错误令人困惑,因为我没有调用任何保管库,也没有使用任何库存。
我手动键入剧本,以防我复制了我不想要的任何内容。
我使用了各种“本地”设置来强制本地化并且没有错误更改。
即使在-vvvv 我只是同样的错误行也无济于事。
如果这是一个模块错误,那为什么要显示一个 Vault 错误?
(我的 ./inventory/group_vars 中确实有保管库,但我不使用它们) 我对此感到头疼。
【问题讨论】:
-
I do have vaults in my ./inventory/group_vars, but I don't use them如果你有它们,无论你以后是否真正使用它们,ansible 都会加载它们。 -
现在,如何阻止它这样做。
-
I don't use any inventory=> 这不是你的 ansible.cfg 所说的。无论如何,ansible 至少会尝试加载默认库存。如何停止:提供 vault_password 或更改不需要的库存。 -
好的,成功了:
ansible-playbook module_test.yml --connection="local 127.0.0.1" --vault-pass "/home/ansible/.ssh/ansible_vault_key" -vv