機能
- アーカイブをアンパックする。アーカイブを含まない圧縮ファイルはアンパックしない。
- デフォルトでは、アンパックする前に、ローカルシステムからターゲットへソースファイルをコピーする。
- ターゲットに既に存在するアーカイブをアンパックするにはremote_src=yesをセットする。
- チェックサムによるバリデーションが必要な場合は、ファイルをフェッチしてremote_src=yesをセットする代わりに、get_urlまたはurlモジュールを使用する。
- Windowsターゲットに関しては、代わりにwin_unzipモジュールを使う。
使用例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
- name: Extract foo.tgz into /var/lib/foo ansible.builtin.unarchive: src: foo.tgz dest: /var/lib/foo - name: Unarchive a file that is already on the remote machine ansible.builtin.unarchive: src: /tmp/foo.zip dest: /usr/local/bin remote_src: yes - name: Unarchive a file that needs to be downloaded (added in 2.0) ansible.builtin.unarchive: src: https://example.com/example.zip dest: /usr/local/bin remote_src: yes - name: Unarchive a file with extra options ansible.builtin.unarchive: src: /tmp/foo.zip dest: /usr/local/bin extra_opts: - --transform - s/^xxx/yyy/ |
参考サイト
ansible.builtin.unarchive module – Unpacks an archive after (optionally) copying it from the local machine — Ansible Documentation
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/unarchive_module.html