From 7b7270c9401449485724202624ec0b59e293d063 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sat, 10 Aug 2019 19:11:10 +0800 Subject: [PATCH] Create `fzf` cookbook. --- cookbooks/fzf/default.rb | 12 ++++++++++ cookbooks/peco/attributes.rb | 10 -------- cookbooks/peco/default.rb | 45 ------------------------------------ roles/base.rb | 2 +- 4 files changed, 13 insertions(+), 56 deletions(-) create mode 100644 cookbooks/fzf/default.rb delete mode 100644 cookbooks/peco/attributes.rb delete mode 100644 cookbooks/peco/default.rb diff --git a/cookbooks/fzf/default.rb b/cookbooks/fzf/default.rb new file mode 100644 index 0000000..776384b --- /dev/null +++ b/cookbooks/fzf/default.rb @@ -0,0 +1,12 @@ +git '/home/kazu634/repo/fzf' do + repository 'https://github.com/junegunn/fzf.git' + user 'kazu634' +end + +link '/home/kazu634/.fzf' do + to '/home/kazu634/repo/fzf' +end + +execute '/home/kazu634/.fzf/install --bin' do + user 'kazu634' +end diff --git a/cookbooks/peco/attributes.rb b/cookbooks/peco/attributes.rb deleted file mode 100644 index 1e5fdf0..0000000 --- a/cookbooks/peco/attributes.rb +++ /dev/null @@ -1,10 +0,0 @@ -# ------------------------------------------- -# Specifying the default settings: -# ------------------------------------------- -node.reverse_merge!({ - 'peco' => { - 'url' => 'https://github.com/peco/peco/releases/download/', - 'tarball' => 'peco_linux_amd64.tar.gz', - 'prefix' => '/usr/local' - } -}) diff --git a/cookbooks/peco/default.rb b/cookbooks/peco/default.rb deleted file mode 100644 index 3dd9044..0000000 --- a/cookbooks/peco/default.rb +++ /dev/null @@ -1,45 +0,0 @@ -include_recipe './attributes.rb' - -# Calculate the latest peco version: -peco_url = '' - -begin - require 'net/http' - - uri = URI.parse('https://github.com/peco/peco/releases/latest') - - Timeout.timeout(3) do - response = Net::HTTP.get_response(uri) - - vtag = $1 if response.body =~ %r{tag\/(v\d+\.\d+\.\d+)} - - peco_url = "#{node['peco']['url']}/#{vtag}/#{node['peco']['tarball']}" - end -rescue - # Abort the chef client process: - raise 'Cannot connect to http://github.com.' -end - -# Download: -TMP = "/tmp/#{node['peco']['tarball']}" - -execute "wget #{peco_url} -O #{TMP}" - -# Install: -INSTALLDIR = '/opt/peco/bin/' -TARGETDIR = '/usr/local/bin/' - -directory INSTALLDIR do - action :create -end - -execute "tar zxf #{TMP} -C #{INSTALLDIR} --strip-components 1" do - action :run -end - -# Make a symlink: -link "#{TARGETDIR}/peco" do - user 'root' - to "#{INSTALLDIR}/peco" - force true -end diff --git a/roles/base.rb b/roles/base.rb index f0f7438..53bd52f 100644 --- a/roles/base.rb +++ b/roles/base.rb @@ -4,6 +4,6 @@ include_recipe '../cookbooks/supervisor/default.rb' include_recipe '../cookbooks/monit/default.rb' include_recipe '../cookbooks/consul/default.rb' include_recipe '../cookbooks/consul-template/default.rb' -include_recipe '../cookbooks/peco/default.rb' +include_recipe '../cookbooks/fzf/default.rb' include_recipe '../cookbooks/fluentd/default.rb' include_recipe '../cookbooks/prometheus/default.rb'