提取模块返回“无法计算远程文件的校验和".在Docker中运行时,但不在Docker中时运行良好 [英] Fetch module returns "unable to calculate the checksum of the remote file" while running in Docker but works fine when not in Docker
问题描述
Ansible剧本(copy_file.yml):
Ansible playbook (copy_file.yml):
- name: Copy this file over please
hosts: all
gather_facts: false
tasks:
- name: Get files from scanners running in each DC
fetch:
src: /tmp/file_to_copy
dest: /tmp/local_place
flat: yes
fail_on_missing: yes
validate_checksum: no
命令:ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory playbook/copy_file.yml
当我运行它时它可以工作.
It works when I run it.
但是当我对其进行docker化时,它会给我带来错误:
But when I dockerize it, it gives me the error:
fatal: [remotehost.com]: FAILED! => {"changed": false, "file": "/tmp/file_to_copy", "msg": "unable to calculate the checksum of the remote file"}
我的dockerfile非常简单.它只是复制一个包含ansible命令的脚本并运行它.其基本图像为Alpine Linux
.
Dockerfile :
My dockerfile is very simple. It just copies a script that contains the ansible command and runs it. Its base image is Alpine Linux
.
Dockerfile:
FROM some_url/alpine/python:3.7-alpine
RUN apk add --no-cache musl-dev libffi-dev openssl-dev
RUN apk add build-base
RUN apk add bash
COPY / /
RUN pip install -r requirements.txt
ENTRYPOINT ["/run.sh"]
Ansible版本:ansible 2.9.2
Ansible version: ansible 2.9.2
推荐答案
Q:*致命:... {" file:"/tmp/file_to_copy," msg:"无法计算远程文件的校验和"}
Q: *"fatal: ... {"file": "/tmp/file_to_copy", "msg": "unable to calculate the checksum of the remote file"}
A:尝试找出为什么状态返回checksum: 0
.例如
A: Try to find out why stat returns checksum: 0
. For example
- hosts: remotehost.com
tasks:
- stat:
path: /tmp/file_to_copy
register: result
- debug:
var: result.stat.checksum
注释
Notes
当校验和为0时报告错误.请参见 lib/ansible/plugins/action/fetch.py
The error is reported when the checksum is 0. See lib/ansible/plugins/action/fetch.py
if remote_checksum == '0':
result['msg'] = "unable to calculate the checksum of the remote file"
- 请参见 lib/ansible/plugins/操作/初始化 .py
- See lib/ansible/plugins/action/init.py
def _remote_checksum(self, path, all_vars, follow=False):
...
x = "0" # unknown error has occurred
try:
remote_stat = self._execute_remote_stat(path, all_vars, follow=follow)
...
x = remote_stat['checksum'] # if 1, file is missing
...
return x # pylint: disable=lost-exception
def _execute_remote_stat(self, path, all_vars, follow, tmp=None, checksum=True):
...
mystat = self._execute_module(module_name='stat', module_args=module_args, task_vars=a
ll_vars, wrap_async=False)
...
return mystat['stat']
这篇关于提取模块返回“无法计算远程文件的校验和".在Docker中运行时,但不在Docker中时运行良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!