致命错误:[本地主机]:失败!=>{“已更改”:错误,“消息”:“无法在Ansible控制器上找到或访问/home/jenkins/workspace/NonProd. json

qrjkbowd  于 2022-11-28  发布在  Jenkins
关注(0)|答案(1)|浏览(265)

在这个问题上的任何帮助都是感激的。
我试图使用Ansible模板将json文件复制到localhost,并运行curl命令导入datadog dasboard。
Jenkins错误:

TASK [datadog-dashboard : Import Datadog Dashboard in main] ********************
16:54:24  included: /home/jenkins/agent/workspace/5052/non_production/monitoring-as-code/src/roles/datadog-dashboard/tasks/Import.yaml for localhost
16:54:24  
16:54:24  TASK [datadog-dashboard : Copying Dashboard json file] *************************
16:54:24  fatal: [localhost]: FAILED! => {"changed": false, "msg": "Could not find or access 'src/roles/datadog-dashboard/templates/datadog-dashboard/non_production/NonProd.json'\nSearched in:\n\t/home/jenkins/agent/workspace/5052/non_production/monitoring-as-code/src/roles/datadog-dashboard/templates/src/roles/datadog-dashboard/templates/datadog-dashboard/non_production/NonProd.json\n\t/home/jenkins/agent/workspace/5052/non_production/monitoring-as-code/src/roles/datadog-dashboard/src/roles/datadog-dashboard/templates/datadog-dashboard/non_production/NonProd.json\n\t/home/jenkins/agent/workspace/5052/non_production/monitoring-as-code/src/roles/datadog-dashboard/tasks/templates/src/roles/datadog-dashboard/templates/datadog-dashboard/non_production/NonProd.json\n\t/home/jenkins/agent/workspace/5052/non_production/monitoring-as-code/src/roles/datadog-dashboard/tasks/src/roles/datadog-dashboard/templates/datadog-dashboard/non_production/NonProd.json\n\t/home/jenkins/agent/workspace/5052/non_production/monitoring-as-code/src/templates/src/roles/datadog-dashboard/templates/datadog-dashboard/non_production/NonProd.json\n\t/home/jenkins/agent/workspace/5052/non_production/monitoring-as-code/src/src/roles/datadog-dashboard/templates/datadog-dashboard/non_production/NonProd.json on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}

Ansible代码:

- name: Copying Dashboard json file
  template:
    src: src/roles/datadog-dashboard/templates/datadog-dashboard/{{ application_env }}/NonProd.json
    dest: /tmp/5052-dash.json
    mode: '0644'
rvpgvaaj

rvpgvaaj1#

它仅适用于以下路径:

templates/datadog-dashboard/{{ application_env }}/NonProd.json

相关问题