【问题标题】:Could not find or access a file that is in the local directory无法找到或访问本地目录中的文件
【发布时间】:2019-08-07 17:11:17
【问题描述】:

当我尝试从本地目录复制到远程目录时,我的项目出现错误

错误信息:

fatal: [xxx]: FAILED! => {
"changed": false, "msg": "could not find 
src=/Users/xxx/Desktop/Docker/The_Task/./roles/docker_registry/templates,
Could not find or access 
'/Users/xxx/Desktop/Docker/The_Task/./roles/docker_registry/templates' 
on the Ansible Controller.\n
If you are using a module and expect the file to exist on the remote, see the remote_src option"
}

playbook.yml

- name: Copying required files
  template:
    src: ./roles/docker_registry/templates
    dest: /tmp/docker_registry

如果我这样做:

cd /Users/xxx/Desktop/Docker/The_Task/./roles/docker_registry/templates

它将目录更改为我想要的目录...错误似乎来自 ansible 方面。 (它不适用于绝对路径八)

如果我使用默认的复制模块,那么它工作得非常好

- name: copy files [local -> remote]
  copy:
    src: ./roles/docker_registry/templates
    dest: /tmp/docker_registry

知道我应该怎么做才能让它工作吗? [它从 LOCAL -> REMOTE 复制]


但我仍然无法将整个目录复制到远程机器中

【问题讨论】:

  • 50% 关闭(仅解决文件,不解决目录)

标签: ansible ansible-template


【解决方案1】:

仅适用于“文件”的解决方案


好的,我会保留这个,以防万一有人偶然发现和我一样的问题...我搞砸的是src: 正在调查角色templates 文件...错误告诉我它访问full path 这是不正确的......它只访问一个templates 文件并且它从那里继续......

固定代码:

- name: Copying required files
  template:
    src: docker-compose.yml
    dest: /tmp/docker_registry

【讨论】:

    猜你喜欢
    • 2012-06-30
    • 1970-01-01
    • 2019-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-23
    • 2016-02-26
    相关资源
    最近更新 更多