treasure-data / chef-td-agent

Chef Cookbook for td-agent (Treasure Agent or Fluentd)
https://supermarket.chef.io/cookbooks/td-agent
Apache License 2.0
127 stars 121 forks source link

Fix support for Amazon Linux in install #95

Closed h3poteto closed 7 years ago

h3poteto commented 7 years ago

Fixed support for Amazon Linux platform family in Chef 13.

Chef-client version

13.2.20

Error

         * yum_package[td-agent] action upgrade
           * No candidate version available for td-agent
           * No candidate version available for td-agent
           * No candidate version available for td-agent
           * No candidate version available for td-agent
           ================================================================================
           Error executing action `upgrade` on resource 'yum_package[td-agent]'
           ================================================================================

           Chef::Exceptions::Package
           -------------------------
           No candidate version available for td-agent

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/td-agent/recipes/install.rb

           116: package "td-agent" do
           117:   retries 3
           118:   retry_delay 10
           119:   if node["td_agent"]["pinning_version"]
           120:     action :install
           121:     version node["td_agent"]["version"]
           122:   else
           123:     action :upgrade
           124:   end
           125: end

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/td-agent/recipes/install.rb:116:in `from_file'

           yum_package("td-agent") do
             package_name "td-agent"
             action [:upgrade]
             default_guard_interpreter :default
             declared_type :package
             cookbook_name "td-agent"
             recipe_name "install"
             retries 3
             retry_delay 10
           end

           System Info:
           ------------
           chef_version=13.2.20
           platform=amazon
           platform_version=2017.03
           ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
           program_name=chef-client worker: ppid=2410;start=14:20:29;
           executable=/opt/chef/bin/chef-client

platform_family of Amazon Linux is judged as amazon in Chef 13, so this recipe skipped creating yum repository.

repeatedly commented 7 years ago

So this code doesn't work on chef-client v12.x?

h3poteto commented 7 years ago

@repeatedly Oh...you are right, certainly this recipe doesn't work on chef 12.x. What should I do...

I can add version restriction in metadata.rb, for example:

chef_version '~> 13'

but, it means that the latest version can not be used in chef 12.x. What do you think?

yyuu commented 7 years ago

I think that the actual incompatibility is in ohai, not chef itself. Anyway Chef 12 is not yet EOL'd and clearly this cookbook should not cut off the support for the version.

h3poteto commented 7 years ago

@yuuu OK, I see. I try to fix this recipe so that it can be used in both versions.

h3poteto commented 7 years ago

I fixed it.