18
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AnsibleでLinuxに最新版のpecoをインストールする

Last updated at Posted at 2014-10-10

pecoのインストールに限った話ではないのですが、githubでreleaseされている最新版をAnsibleでインストールしたいことがあって書いた。Macだとbrew install 一発なんだけど、Linuxで使いたかったので。

tl;dr

完成形

peco.yml
- name: Get latest peco version
  shell: >
    curl -sI https://github.com/peco/peco/releases/latest | awk -F'/' '/^Location:/{print $NF}'
      register: peco_latest_version

- name: Download latest peco
  get_url: url=https://github.com/peco/peco/releases/download/{{ peco_latest_version.stdout }}/peco_linux_amd64.tar.gz dest=/tmp/peco_linux_amd64.tar.gz

- name: Extract peco
  unarchive: src=/tmp/peco_linux_amd64.tar.gz dest=/tmp/

- name: Copy to /usr/bin/
  copy: src=/tmp/peco_linux_amd64/peco dest=/usr/bin/ mode=0755

最新バージョンを取得

インストール時に一番新しいのを使いたいので自動で最新版を取得する。

- name: Get latest peco version
  shell: >
    curl -sI https://github.com/peco/peco/releases/latest | awk -F'/' '/^Location:/{print $NF}'
  register: peco_latest_version

https://github.com/peco/peco/releases/latest にアクセスしてredirect先のurlを取得して、awkでバージョンを切り出し、peco_latest_versionに格納。

ダウンロードして、コピー

- name: Download latest peco
  get_url: url=https://github.com/peco/peco/releases/download/{{ peco_latest_version.stdout }}/peco_linux_amd64.tar.gz dest=/tmp/peco_linux_amd64.tar.gz

- name: Extract peco
  unarchive: src=/tmp/peco_linux_amd64.tar.gz dest=/tmp/

- name: Copy to /usr/bin/
  copy: src=/tmp/peco_linux_amd64/peco dest=/usr/bin/ mode=0755
  1. https://github.com/peco/peco/releases/download/{{ peco_latest_version.stdout }}/peco_linux_amd64.tar.gzからダウンロード
  2. 解凍
  3. /usr/binにパーミッション指定してcopy

参考

18
16
1

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
18
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?