无法对 /etc/ 下的文件使用查找文件模块

Could not use lookup file module for a file under /etc/

我正在部署一台 CentOS 机器,其中一项任务是读取一个呈现 Consul 服务的文件,该服务将其置于 /etc/sysconfig 下。我稍后尝试使用 lookup 模块在变量中读取它,但它在下面抛出错误:

fatal: [ansible_vm1]: FAILED! => {"failed": true, "msg": "could not locate file in lookup: /etc/sysconfig/idb_EndPoint"}

但我 运行 查找任务低于生成 idb_EndPoint 文件的位置,我还手动查找它登录以验证文件是否可用。

 - name: importing the file contents to variable
   set_fact:
     idb_endpoint: "{{ lookup('file', '/etc/sysconfig/idb_EndPoint') }}"
   become: true

我还尝试了与另一个用户 become_user: deployuser 以及 become: true 的特权升级,但仍然没有成功。使用 Ansible 版本 2.2.1.0.

Ansible中的所有查找插件都在控制机器上本地执行。

改为使用slurp module:

- name: importing the file contents to variable
  slurp:
    src: /etc/sysconfig/idb_EndPoint
  register: idb_endpoint_b64
  become: true

- set_fact:
    idb_endpoint: "{{ idb_endpoint_b64.content | b64decode }}"