LoginSignup
3
4

More than 5 years have passed since last update.

Ansible の unarchive でリモートのアーカイブの中から1つのファイルだけ展開する

Posted at

サクッとできそうでできない。

- unarchive:
    src: https://github.com/prometheus/node_exporter/releases/download/v0.13.0/node_exporter-0.13.0.linux-amd64.tar.gz
    dest: /usr/local/bin/
    creates: /usr/local/bin/node_exporter
    remote_src: yes
    owner: root
    group: root
    extra_opts:
      - --strip-components=1
      - node_exporter-0.13.0.linux-amd64/node_exporter

要するに下記とだいたい同じ。

curl -s http://shs-opr:8080/next/thirdparty/prometheus/node_exporter-0.13.0.linux-amd64.tar.gz |
  sudo tar xvzf - --no-same-owner --directory=/usr/local/bin \
    --strip-components=1 -- node_exporter-0.13.0.linux-amd64/node_exporter

extra_opts でがんばるのが泥臭いしこれなら shell で良いんじゃない?、という気もします。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4