gpt4 book ai didi

Ansible Unarchive 命令导致错误 "Failed to find handler"

转载 作者:行者123 更新时间:2023-12-02 16:50:51 24 4
gpt4 key购买 nike

我使用 Ansible 在 EC2 上运行 AmazonLinux2。但是,当执行 Unarchive 命令时,会显示以下错误。

"Failed to find handler for \"/tmp/hoge.db.gz\".   
Make sure the required command to extract the file is installed.
Command \"/usr/bin/unzip\" could not handle archive. Command \"/usr/bin/gtar\" could not handle archive."

PlayBook的内容如下。

- name: Unarchive hoge
become: yes
unarchive:
src: /tmp/hoge.db.gz
dest: /root/fuga/
remote_src: yes

以下是我为确定错误原因而检查的信息。

  • 取消存档需要命令
[root@ip- ~]# which gtar
/usr/bin/gtar
[root@ip- ~]# which unzip
/usr/bin/unzip
[root@ip- ~]# which zipinfo
/usr/bin/zipinfo
  • 路径
- debug:
var: ansible_env.PATH
"ansible_env.PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"

最佳答案

unarchive 模块无法处理 gzip 文件,除非它们是压缩的 tar 包(参见 https://docs.ansible.com/ansible/latest/modules/unarchive_module.html)。

您需要先使用copy 模块复制gzip 文件,然后使用shell 模块使用gunzip 解压缩它。

例子:

- copy:
src: /tmp/hoge.db.gz
dest: /root/fuga/hoge.db.gz
- shell: gunzip /root/fuga/hoge.db.gz

您可能需要先在托管主机上安装 gunzip

关于Ansible Unarchive 命令导致错误 "Failed to find handler",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58792859/

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