Skip to content

Instantly share code, notes, and snippets.

@massat
Last active December 15, 2015 20:18
Show Gist options
  • Save massat/5317095 to your computer and use it in GitHub Desktop.
Save massat/5317095 to your computer and use it in GitHub Desktop.
適当に書き始めたけど define の中で rpm_package が使えないのはなんでなの
#
# Cookbook Name:: mysql
# Definition:: mysql_package
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
define :mysql_package do
execute "install-#{params[:name]}" do
package = params[:name]
version = node['mysql']['version']
minor_version = version.to_f
arch = node[:kernel][:machine]
rpm_file = "MySQL-#{package}-#{version}-1.linux_glibc2.5.#{arch}.rpm"
remote_file "#{Chef::Config[:file_cache_path]}/#{rpm_file}" do
source "http://dev.mysql.com/get/Downloads/MySQL-#{minor_version}/#{rpm_file}/from/http://cdn.mysql.com/"
not_if "rpm -qa | grep -q '^MySQL-#{package}'"
notifies :install, "rpm_package[mysql-#{package}]", :immediately
end
rpm_package "mysql-#{package}" do
source "#{Chef::Config[:file_cache_path]}/#{rpm_file}"
only_if { ::File.exists?("#{Chef::Config[:file_cache_path]}/#{rpm_file}")}
action :nothing
end
file "mysql-#{package}-cleanup" do
path "#{Chef::Config[:file_cache_path]}/#{rpm_file}"
action :delete
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment