我使用 Ansible 在 EC2 上运行 AmazonLinux2。但是,当执行取消归档命令时,会显示以下错误。
"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."
Run Code Online (Sandbox Code Playgroud)
PlayBook的内容如下。
- name: Unarchive hoge
become: yes
unarchive:
src: /tmp/hoge.db.gz
dest: /root/fuga/
remote_src: yes
Run Code Online (Sandbox Code Playgroud)
以下是我检查过的信息,以确定错误原因。
"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."
Run Code Online (Sandbox Code Playgroud)
- name: Unarchive hoge
become: yes
unarchive:
src: /tmp/hoge.db.gz
dest: /root/fuga/
remote_src: yes
Run Code Online (Sandbox Code Playgroud)
"ansible_env.PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
Run Code Online (Sandbox Code Playgroud)
该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
Run Code Online (Sandbox Code Playgroud)
您可能需要首先在托管主机上安装gunzip
归档时间: |
|
查看次数: |
15404 次 |
最近记录: |