{"action":"created","issue":{"url":"https://api.github.com/repos/itamae-kitchen/itamae/issues/132","labels_url":"https://api.github.com/repos/itamae-kitchen/itamae/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/itamae-kitchen/itamae/issues/132/comments","events_url":"https://api.github.com/repos/itamae-kitchen/itamae/issues/132/events","html_url":"https://github.com/itamae-kitchen/itamae/issues/132","id":77086823,"number":132,"title":"Supporting provider for service resource like chef","user":{"login":"sonots","id":2290461,"avatar_url":"https://avatars.githubusercontent.com/u/2290461?v=3","gravatar_id":"","url":"https://api.github.com/users/sonots","html_url":"https://github.com/sonots","followers_url":"https://api.github.com/users/sonots/followers","following_url":"https://api.github.com/users/sonots/following{/other_user}","gists_url":"https://api.github.com/users/sonots/gists{/gist_id}","starred_url":"https://api.github.com/users/sonots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonots/subscriptions","organizations_url":"https://api.github.com/users/sonots/orgs","repos_url":"https://api.github.com/users/sonots/repos","events_url":"https://api.github.com/users/sonots/events{/privacy}","received_events_url":"https://api.github.com/users/sonots/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-16T17:28:06Z","updated_at":"2015-05-18T04:23:43Z","closed_at":null,"body":"I want to have `provider` attribute for `service` resource which chef has. \r\n\r\nIn the chef, writing `service` resource like below allows us to change the service command to `upstart`. \r\n```ruby\r\nservice \"example_service\" do\r\n  action :start\r\n  provider Chef::Provider::Service::Upstart\r\n  notifies :restart, \"service[nginx]\", :immediately\r\nend\r\n```\r\n\r\nAlso, with writing a gem like https://github.com/hirose31/chef-provider-service-daemontools, we add a provider `Chef::Provider::Service::Daemontools` to change the service commands to one of daemontools. \r\n\r\nI am willing to implement this, but I want to disscuss the implementation design beforehand. \r\n\r\n### 1) under way\r\n\r\nSpecinfra has some of `check_is_running_under_#{provider}` methods already like [this](https://github.com/serverspec/specinfra/blob/8978d69e5804978ff2252f20c5e8ec91ba25fe0c/lib/specinfra/command/base/service.rb#L11-L17), so one way would be to change `lib/itamae/resource/service.rb` as this patch > https://gist.github.com/sonots/0b601f610b04d2c27cdd. And, add `xxx_under_xxx` methods to specinfra. \r\n\r\n### 2) module way\r\n\r\nSpecinfra has `Specinfra::Command::Module::Systemd` at [lib/specinfra/command/module/systemd.rb](https://github.com/serverspec/specinfra/blob/d4a29586dc59540333e135fff07a0588994175db/lib/specinfra/command/module/systemd.rb), so one way would be to support to specify a module with `provider` attribute, and mixin it on calling `run_specinfra` by some ways. \r\n\r\n### 3) resource way\r\n\r\nGiving up to provide `provider` attribute, and implement the feature as another `resource` like\r\n\r\n```\r\ndaemontools_service \"foo\" do\r\n  action :start\r\nend\r\n```\r\n\r\nI think this design is heavily related with the implementation design in `specinfra`, so it is better to discuss with both @mizzy and @ryotarai. \r\n\r\nEDIT: I also want to have `provider` attribute for `package` resource like chef > https://docs.chef.io/resource_package.html. Chef allows us to specify `provider Chef::Provider::Package::Rpm`, also chef provides `rpm_package` **resource** in this case. \r\n\r\nPlease let me know if there is a discussion already. \r\n"},"comment":{"url":"https://api.github.com/repos/itamae-kitchen/itamae/issues/comments/102917979","html_url":"https://github.com/itamae-kitchen/itamae/issues/132#issuecomment-102917979","issue_url":"https://api.github.com/repos/itamae-kitchen/itamae/issues/132","id":102917979,"user":{"login":"sonots","id":2290461,"avatar_url":"https://avatars.githubusercontent.com/u/2290461?v=3","gravatar_id":"","url":"https://api.github.com/users/sonots","html_url":"https://github.com/sonots","followers_url":"https://api.github.com/users/sonots/followers","following_url":"https://api.github.com/users/sonots/following{/other_user}","gists_url":"https://api.github.com/users/sonots/gists{/gist_id}","starred_url":"https://api.github.com/users/sonots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonots/subscriptions","organizations_url":"https://api.github.com/users/sonots/orgs","repos_url":"https://api.github.com/users/sonots/repos","events_url":"https://api.github.com/users/sonots/events{/privacy}","received_events_url":"https://api.github.com/users/sonots/received_events","type":"User","site_admin":false},"created_at":"2015-05-18T04:23:43Z","updated_at":"2015-05-18T04:23:43Z","body":"@mizzy To support \"1) under way\", we need to add lots of methods like `start_under_daemontools`, `start_under_upstart`, `enable_under_daemontools` to specinfra. I want to hear an opinion from the author of specifra. "}}