我正在使用ansible-module-hashivault模块来管理hashicorp保险库。这样做(主要)在localhost上使用ansible,因此,我的剧本完全在localhost上运行。我希望使用this SO question中的回调,以JSON格式存储所有日志。
除了一点小烦恼,我一切正常。当我运行剧本时,会收到以下警告,这些警告不会通过回调。我已经从文档中尝试了所有带有“警告”的env变量,并且这些警告似乎都没有禁用它们。如何抑制这些或将其发送到回调函数进行格式化?
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
答案 0 :(得分:2)
出现警告有两个原因
/etc/ansible/hosts
,这是系统默认清单
丢失了要解决此问题,请先在ansible剧本目录中创建一个名为ansible.cfg
的文件,然后放入其中
inventory = inventory
因此,我们宣布将您的库存文件设置为本地目录中名为inventory
的文件中。
现在创建文件inventory
并放入
[defaults]
localhost ansible_connection=local
声明本地主机目标。 那应该删除警告