Chef! Where is my Ubuntu 14.04 service support?

So you’ve decided to update or use Ubuntu 14.04 LTS. You’ve probably started leveraging Chef in some awesome way. The problem is, you put in a nice little service Resource and see something like:

/usr/sbin/update-rc.d <some\_awesome\_service> defaults returned 1, expected 0

This is frustrating because Ubuntu 14.04 decided to ship with two different init systems. Upstart is the default init system, but most services are still in the SysV init.

The tl;dr, if you have a service Resource that fails with something like the above error you can add the Provider like this:

If you’re Ubuntu 14.04 only:

service "some\_awesome\_service" do
  provider Chef::Provider::Service::Upstart
  supports :restart => true
  action [:enable,:start]

If you’re >= Ubuntu 12.04 and Ubuntu 14.04 with some conditional logic:

service "some\_awesome\_service" do
  case node["platform"]
  when "ubuntu"
    if node["platform\_version"].to\_f >= 14.04
      provider Chef::Provider::Service::Upstart
  action [:enable, :start]
  supports :restart => true

Chef attempted to cover the majority of the use cases and defaults to the SysV init system for Ubuntu. Take for instance the openssh cookbook has this work around already built in. An RFC has been opened to discuss the challenge that if we change it to Upstart, we’ll break 1/2 of major services using SysV.

We’d like to tip our hat to a community member: Matthew McMillan for his post about a work around for this issue. We’ve leveraged it a few places, and it’s the current best short term answer.

Ubuntu 14.04 is going to be around until at least April 2019, and we are trying to figure out the correct solution. Let’s continue discussing this at the Chef Summit, or you’re more than welcome to comment on the RFC.

Posted in:

JJ Asghar

JJ works with Strategic Technical Alliances at Chef Software making integrations work with Chef, Habitat, and InSpec. He works on everything from Azure, VMware, OpenStack, and Cisco with everything in between. He also heads up the Chef Partner Cookbook Program to make sure customers of Chef and vendors get the highest quality certified cookbooks. He grew up and currently lives in Austin, Texas.

Chefconf Blog Banner Bottom

Chefconf Blog Banner Sidebar
Survey Blog Banner Sidebar