puppet service enable broken on ubuntu vivid with debian provider

Bug #1495853 reported by Tero Marttila
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
puppet (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Running Puppet on Ubuntu 15.04 Vivid:

 $ lsb_release -d
 Description: Ubuntu 15.04

 $ apt-cache policy puppet-common
 puppet-common:
  Installed: 3.7.2-1ubuntu2

Using the bird package as an example, which ships both sysvinit and systemd service files:

 $ dpkg -L bird | vgrep service unit files
 /lib/systemd/system/bird.service
 /lib/systemd/system/bird6.service
 /etc/init.d/bird6
 /etc/init.d/bird
 /etc/init/bird.conf
 /etc/init/bird6.conf

Puppet appears to choose the debian provider for the bird service, over the systemd provider:

 $ sudo puppet resource --debug --param provider --param enable service bird
 Debug: Runtime environment: puppet_version=3.7.2, ruby_version=2.1.2, run_mode=user, default_encoding=UTF-8
 ...
 Debug: /Service[bird]: Provider debian does not support features flaggable; not managing attribute flags
 ...
 Debug: Service bird found in both debian and init; skipping the init version
 ...
 Debug: /Service[bird.service]: Provider systemd does not support features flaggable; not managing attribute flags
 ...
 Debug: Executing '/etc/init.d/bird status'
 service { 'bird':
   ensure => 'stopped',
   enable => 'true',
   provider => 'debian',
 }

This means that while `ensure => running/stopped` works:

 $ sudo puppet resource --debug --param provider service bird ensure=stopped
 Debug: Executing '/etc/init.d/bird status'
 Debug: Executing '/etc/init.d/bird stop'
 Notice: /Service[bird]/ensure: ensure changed 'running' to 'stopped'
 Debug: Finishing transaction 3255100
 Debug: Storing state
 Debug: Stored state in 0.13 seconds
 Debug: Executing '/etc/init.d/bird status'
 service { 'bird':
   ensure => 'stopped',
   provider => 'debian',
 }

The service `enabled => true/false` state does not:

 $ sudo puppet resource --debug --param provider service bird enable=false
 Debug: Executing '/etc/init.d/bird status'
 Debug: Executing '/usr/sbin/update-rc.d bird disable'
 Notice: /Service[bird]/enable: enable changed 'true' to 'false'
 Debug: Finishing transaction 23676980
 Debug: Storing state
 Debug: Stored state in 0.12 seconds
 Debug: Executing '/etc/init.d/bird status'
 service { 'bird':
   ensure => 'stopped',
   enable => 'false',
   provider => 'debian',
 }
 $ sudo puppet resource --debug --param provider service bird enable=true
 Debug: Executing '/etc/init.d/bird status'
 Debug: Executing '/usr/sbin/update-rc.d -f bird remove'
 Debug: Executing '/usr/sbin/update-rc.d bird defaults'
 Notice: /Service[bird]/enable: enable changed 'false' to 'true'
 Debug: Finishing transaction 12984740
 Debug: Storing state
 Debug: Stored state in 0.14 seconds
 Debug: Executing '/etc/init.d/bird status'
 service { 'bird':
   ensure => 'stopped',
   enable => 'true',
   provider => 'debian',
 }
 $ ls /etc/rc?.d/*bird*
 /etc/rc0.d/K01bird /etc/rc1.d/K01bird6 /etc/rc3.d/K01bird6 /etc/rc4.d/S02bird /etc/rc6.d/K01bird
 /etc/rc0.d/K01bird6 /etc/rc2.d/K01bird6 /etc/rc3.d/S02bird /etc/rc5.d/K01bird6 /etc/rc6.d/K01bird6
 /etc/rc1.d/K01bird /etc/rc2.d/S02bird /etc/rc4.d/K01bird6 /etc/rc5.d/S02bird
 $ sudo systemctl is-enabled bird
 disabled

I presume that systemd ignores any sysvinit configuration (/etc/rc?.d/*) for services that have a native systemd unit, and is thus blind to any state inspected/changed by puppet's debian service provider.

Workaround is to explcitly use the systemd provider for the service shipping a native systemd service unit:

 $ sudo puppet resource --debug --param provider --param enable service bird provider=systemd enable=true
 Warning: Setting manifest is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
 Debug: Executing '/bin/systemctl is-active bird'
 Debug: Executing '/bin/systemctl is-enabled bird'
 Debug: Executing '/bin/systemctl enable bird'
 Notice: /Service[bird]/enable: enable changed 'false' to 'true'
 Debug: Finishing transaction 14759420
 Debug: Storing state
 Debug: Stored state in 0.20 seconds
 Debug: Executing '/bin/systemctl is-active bird'
 Debug: Executing '/bin/systemctl is-enabled bird'
 service { 'bird':
   ensure => 'stopped',
   enable => 'true',
   provider => 'systemd',
 }
 $ sudo systemctl is-enabled bird
 enabled

Revision history for this message
Tero Marttila (terom-u) wrote :

Note that the same scenario behaves correctly under Debian jessie, with the patched debian service provider in version 3.7.2-3:

 https://bugs.debian.org/775795

Similar example on a Debian jessie system:

 $ sudo lsb_release -d
 Description: Debian GNU/Linux 8.2 (jessie)
 $ apt-cache policy puppet
 puppet:
   Installed: 3.7.2-4
   Candidate: 3.7.2-4
   Version table:
  *** 3.7.2-4 0
  500 http://apt/debian/ jessie/main amd64 Packages
  100 /var/lib/dpkg/status
 $ dpkg -L bird | vgrep ...
 /etc/init/bird.conf
 /etc/init/bird6.conf
 /etc/init.d/bird
 /etc/init.d/bird6
 /lib/systemd/system/bird.service
 /lib/systemd/system/bird6.service

 $ sudo puppet resource --debug --param provider --param enable service bird
 Debug: Executing '/usr/sbin/service bird status'
 Debug: Executing '/bin/systemctl show -pSourcePath bird'
 Debug: Executing '/bin/systemctl is-enabled bird'
 service { 'bird':
   ensure => 'running',
   enable => 'true',
   provider => 'debian',
 }
 $ sudo puppet resource --debug --param provider --param enable service bird enable=false
 Debug: Executing '/usr/sbin/service bird status'
 Debug: Executing '/bin/systemctl show -pSourcePath bird'
 Debug: Executing '/bin/systemctl is-enabled bird'
 Debug: Executing '/bin/systemctl disable bird'
 Notice: /Service[bird]/enable: enable changed 'true' to 'false'
 Debug: Finishing transaction 16554200
 Debug: Storing state
 Debug: Stored state in 0.29 seconds
 Debug: Executing '/usr/sbin/service bird status'
 Debug: Executing '/bin/systemctl show -pSourcePath bird'
 Debug: Executing '/bin/systemctl is-enabled bird'
 service { 'bird':
   ensure => 'running',
   enable => 'false',
   provider => 'debian',
 }
 $ sudo puppet resource --debug --param provider --param enable service bird enable=true
 Debug: Executing '/usr/sbin/service bird status'
 Debug: Executing '/bin/systemctl show -pSourcePath bird'
 Debug: Executing '/bin/systemctl is-enabled bird'
 Debug: Executing '/bin/systemctl enable bird'
 Notice: /Service[bird]/enable: enable changed 'false' to 'true'
 Debug: Finishing transaction 18953360
 Debug: Storing state
 Debug: Stored state in 0.21 seconds
 Debug: Executing '/usr/sbin/service bird status'
 Debug: Executing '/bin/systemctl show -pSourcePath bird'
 Debug: Executing '/bin/systemctl is-enabled bird'
 service { 'bird':
   ensure => 'running',
   enable => 'true',
   provider => 'debian',
 }

Tero Marttila (terom-u)
summary: - puppet service enable broken on ubuntu vivid for services shipping
- sysvinit and systemd support
+ puppet service enable broken on ubuntu vivid with debian provider
description: updated
Revision history for this message
Robie Basak (racb) wrote :

I wonder if this is related to bug 1457957? Ryan, as you're assigned that bug, could you take a look at this one at the same time please?

Changed in puppet (Ubuntu):
assignee: nobody → Ryan Harper (raharper)
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in puppet (Ubuntu):
status: New → Confirmed
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I checked this on Xenial again since we have puppet 3.8.5-2 merged (and also Debian/Ubunut + Systemd is longer in the field)

First of all bird is still as it was back then, so it should be good to trigger the issue again in repro.

I was able to confirm that things work back to Wily.
They follow what was initially reported, but like the Report for Debian with 3.7.2-3 it now works in Ubuntu as well.
 puppet | 3.7.2-5ubuntu2 | wily | source, all
 puppet | 3.8.5-2 | xenial/universe | source, all

I can see these and it works:
[...]
Debug: Executing '/usr/sbin/service bird status'
Debug: Executing '/bin/systemctl show -pSourcePath bird'
Debug: Executing '/bin/systemctl is-enabled bird'
Debug: Executing '/bin/systemctl enable bird'
Notice: /Service[bird]/enable: enable changed 'false' to 'true'
Debug: Finishing transaction 20754640
Debug: Storing state
Debug: Stored state in 0.01 seconds
Debug: Executing '/usr/sbin/service bird status'
Debug: Executing '/bin/systemctl show -pSourcePath bird'
Debug: Executing '/bin/systemctl is-enabled bird'
[...]

Note: thanks a lot for the great bug report including reproducing steps that really work well.
There is a known issue in case upstart is installed - not 100% a dup, that is tracked in bug 1457957

Changed in puppet (Ubuntu):
status: Confirmed → Fix Released
importance: Undecided → Medium
assignee: Ryan Harper (raharper) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.