Create `fzf` cookbook.

This commit is contained in:
Kazuhiro MUSASHI 2019-08-10 19:11:10 +08:00
parent 9393f44a64
commit 7b7270c940
4 changed files with 13 additions and 56 deletions

12
cookbooks/fzf/default.rb Normal file
View File

@ -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

View File

@ -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'
}
})

View File

@ -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

View File

@ -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'