gpt4 book ai didi

docker - Ansible:如何复制环境文件?

转载 作者:行者123 更新时间:2023-12-02 21:32:54 25 4
gpt4 key购买 nike

我正在尝试在远程服务器上复制docker-compose文件和env文件,但是ansible能够复制docker-compose文件,但对于env文件似乎不起作用。
这是我得到的错误:-

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [10.19.x.x]: FAILED! => {"changed": false, "msg": "Could not find or access '/home/ubuntu/git/files/env' on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}
这是我的烦人的剧本:
---

- name: Write docker-compose files
become: yes
copy:
src: /home/ubuntu/git/files/docker-compose.yml
dest: /home/remote/docker-compose.yml

- name: Write env files
become: yes
copy:
src: /home/ubuntu/git/files/env
dest: /home/remote/env


- name: Run docker service
become: yes
docker_compose:
project_src: /home/remote/
这是我运行Ansible剧本时的输出:-
PLAY [configure redash-server] **************************************************************************************************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************************************************************************************************************
[DEPRECATION WARNING]: Distribution Ubuntu 16.04 on host 10.19.x.x should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will
default to using the discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in
version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ok: [10.19.x.x]

TASK [redash-version-8 : Write docker-compose files] ****************************************************************************************************************************************************************
ok: [10.19.x.x]

TASK [redash-version-8 : Write env files] ***************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [10.19.x.x]: FAILED! => {"changed": false, "msg": "Could not find or access '/home/psharma/git/files/env' on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}

PLAY RECAP **********************************************************************************************************************************************************************************************************
10.19.x.x : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
我在Ubuntu 20.04上运行最新版本的ansible(2.9.12)。任何帮助将不胜感激。谢谢

最佳答案

您确定使用正确的文件路径/文件名吗?可能是.env而不是env吗?
如果文件名和路径正确,则可能是文件上的文件权限不正确。如果这是个人计算机,则可以尝试使用正确目录中的chmod 777 env之类的方法来更改env文件的权限。
无论如何,目录ls -al/home/ubuntu/git/files/的输出可能有助于进一步研究该问题。

关于docker - Ansible:如何复制环境文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64033292/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com