Chef failed to install Docker when using attribute default['docker']['version']


#1

Hi Team,

I have a recipe for installing particular version of docker. I specified the version of docker through attribute. I just used the attribute node.default[‘docker’][‘version’] = ‘1.12.6-1.el7.centos’ . The recipe executed successfully for the first time but it failed when run on second time.

It executed successfully on multiple converges when I used any attribute other than default[‘docker’][‘version’] say node.default[‘docker’][‘xyz’] = ‘1.12.6-1.el7.centos’

Can anyone know why it failed when using default[‘docker’][‘version’]

[root@master01 package]# cat _docker.rb
node.default['docker']['version'] = '1.12.6-1.el7.centos'
package "lvm2"
package "device-mapper-persistent-data"

directory "/var/lib/docker"

directory "/etc/docker" do
owner "root"
group "root"
mode "0744"
action :create
recursive true
end

package 'docker-engine' do
version node['docker']['version']
allow_downgrade true
end
service "docker" do
action :enable
end

Below, I used attribute node.default[‘docker’][‘xyz’] = ‘1.12.6-1.el7.centos’ and chef successfully ran the recipe.

[root@master01 package]# cat _docker.rb
node.default['docker']['xyz'] = '1.12.6-1.el7.centos'

package 'docker-engine' do
version node['docker']['xyz']
allow_downgrade true
end

[root@master01 package]# /opt/chef/bin/chef-apply _docker.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)

  • yum_package[lvm2] action install (up to date)
  • yum_package[device-mapper-persistent-data] action install (up to date)
  • directory[/var/lib/docker] action create (up to date)
  • directory[/etc/docker] action create (up to date)
  • yum_package[docker-engine] action install
    • install version 1.12.6-1.el7.centos of package docker-engine

Following is the error I received when using default[‘docker’][‘version’] attribute.

[root@master01 package]# /opt/chef/bin/chef-apply _docker.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)

  • yum_package[lvm2] action install (up to date)

  • yum_package[device-mapper-persistent-data] action install (up to date)

  • directory[/var/lib/docker] action create (up to date)

  • directory[/etc/docker] action create (up to date)

  • yum_package[docker-engine] action install

    • No candidate version available for docker-engine
      ================================================================================
      Error executing action install on resource ‘yum_package[docker-engine]’
      ================================================================================

    Chef::Exceptions::Package

    No candidate version available for docker-engine

    Resource Declaration:

    In _docker.rb

    16: package ‘docker-engine’ do
    17: version node[‘docker’][‘version’]
    18: # version node[‘docker’][‘version’]
    19: allow_downgrade true
    20: end
    21:

    Compiled Resource:

    Declared in _docker.rb:16:in `run_chef_recipe’

    yum_package(“docker-engine”) do
    package_name “docker-engine”
    action [:install]
    default_guard_interpreter :default
    declared_type :package
    cookbook_name “(chef-apply cookbook)”
    recipe_name “(chef-apply recipe)”
    version “17.03.2”
    allow_downgrade true
    end

    System Info:

    chef_version=14.2.0
    platform=centos
    platform_version=7.4.1708
    ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
    program_name=/opt/chef/bin/chef-apply
    executable=/opt/chef/bin/chef-apply

[2018-07-05T07:40:49+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2018-07-05T07:40:49+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-07-05T07:40:49+00:00] FATAL: Chef::Exceptions::package: yum_package[docker-engine] ((chef-apply cookbook)::(chef-apply recipe) line 16) had an error: Chef::Exceptions::package: No candidate version available for docker-engine

Chef Version

chef_version=14.2.0
ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
program_name=/opt/chef/bin/chef-apply
executable=/opt/chef/bin/chef-apply

Platform Version

platform=centos
platform_version=7.4.1708

I checked and confirmed that the version specified is available in our custom repository and I can able to install it manually using yum. Can anyone help me what is the reason behaind this behavior ?