sous-chefs / docker

Development repository for the docker cookbook
https://supermarket.chef.io/cookbooks/docker
Apache License 2.0
1.35k stars 794 forks source link

Support Devuan #780

Open ttr opened 7 years ago

ttr commented 7 years ago

Cookbook version

docker (2.9.7)

Chef-client version

Chef Client, version 12.15.19

Platform Details

Devuan 1.0 (Debain jessie fork)

Scenario:

Install / configure docker service using sysvint

Steps to Reproduce:

On Devuan there is no systemd. Trying to configure service using automethod will default to systemd (as platform family is debian, version above 8.0) For this purpose I have node['init_package'] override to init (this is defined in chef-client cookbook, used quite common) AND also defined sysvinit as service_manager when defining docker definition.

docker_service 'default' do
  service_manager 'sysvinit'
  action [:create, :start]
end

Expected Result:

Docker is configured by desired init system

Actual Result:

'Chef::Exceptions::NoSuchResourceType
------------------------------------
Cannot find a resource for docker_service_manager_sysvinit on debian version 8.5
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb:308:in `build_resource'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb:265:in `declare_resource'
/var/chef/cache/cookbooks/docker/libraries/docker_service.rb:78:in `svc_manager'
/var/chef/cache/cookbooks/docker/libraries/docker_service.rb:109:in `block in <class:DockerService>'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:132:in `instance_eval'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:132:in `compile_and_converge_action'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in `run_action'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block (2 levels) in converge'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `each'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block in converge'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in `converge'

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/ttr-docker/recipes/install_docker.rb

 14: docker_service 'default' do
 15:   service_manager node['docker']['service']['service_manager']
 16:   action [:create, :start]
 17:   storage_driver node['docker']['service']['storage_drver']
 18:   storage_opts node['docker']['service']['storage_opts']
 19:   log_driver 'syslog'
 20:   log_opts ['syslog-facility=local5', 'tag={{.ImageName}}/{{.Name}}']
 21: end
 22:

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/ttr-docker/recipes/install_docker.rb:14:in `from_file'

docker_service("default") do
  action [:create, :start]
  retries 0
  retry_delay 2
  default_guard_interpreter :default
  declared_type :docker_service
  cookbook_name "ttr-docker"
  recipe_name "install_docker"
  service_manager "sysvinit"
  storage_driver ["overly"]
  storage_opts ["dm.basesize=10G"]
  log_driver "syslog"
  log_opts ["syslog-facility=local5", "tag={{.ImageName}}/{{.Name}}"]
  install_method "auto"
end'
someara commented 7 years ago

You'll have to use the underlying resources manually

docker_installation_package 'default' do
  blah blh
end
docker_service_manager_sysvinit_debian 'default' do
   blah blah
end
someara commented 7 years ago

PS: You should work on getting a Devuan platform def into Ohai

ttr commented 7 years ago

ah. Docs menrtioned "docker_service_manager_sysvinit" and that did not work, docker_service_manager_sysvinit_debian with some polishing did the trick.

Yes - there is on my list to see what is missing in ohai and others but honestly, not enough time recently.

Thanks.

ttr commented 7 years ago

actually there is still small issue. in /etc/default/docker DOCKER variable is getting set to empty string DOCKER=""

while DOCKER_OPTS are generated correctly

Approached this differently - did wrapper recipe for libraries/docker_service_manager_sysvinit_debian.rb and changed versions for debian, but yes, this needs to be fixed in ohai.

Thx.

tas50 commented 7 years ago

We can actually fix this without even adding the platform specifically into Ohai. We just need to switch the provides logic in the resources from specifying platforms to specifying init systems. I'm in the process of doing this with mysql and tomcat cookbooks. It simplifies the code and makes it work on more obscure platforms.