Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-5296

Puppet 4.2.x agent for RHEL 7 enables System V init scripts services on each run

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 4.2.0, PUP 4.2.1, PUP 4.2.2, PUP 4.2.3, PUP 4.3.0, PUP 4.3.1, PUP 4.3.2, PUP 4.4.0, PUP 4.4.1
    • Fix Version/s: PUP 4.5.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      Client 2016-04-20
    • CS Priority:
      Reviewed
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      Previously, SysVinit services running on RedHat systems which use systemd as the default init system were not being properly queried for `enable` status by the systemd provider. The provider has been updated to use a backwards-compatible `systemctl` command to ensure all services can be properly queried.
      Show
      Previously, SysVinit services running on RedHat systems which use systemd as the default init system were not being properly queried for `enable` status by the systemd provider. The provider has been updated to use a backwards-compatible `systemctl` command to ensure all services can be properly queried.

      Description

      Overview

      Puppet 4.2.1 agent for EL7 enables System V init scripts services on each run

      Expected behaviour

      System V service does not provide a UnitFileState. systemd.rb should include the check the service's state with

      systemctl("is-enabled", @resource[:name]).
      

      Like in PE versions before 2015.2

      Also, SysV init scripts in EL7 should have 'redhat' provider instead of 'init' for it to work.

      Actual behaviour

      Each agent run for EL7 enables System V init scripts services.

      # puppet agent -t 
      Info: Retrieving pluginfacts 
      Info: Retrieving plugin 
      Info: Loading facts 
      Info: Caching catalog for df-rhel7 
      Info: Applying configuration version '1442494617' 
      Notice: /Stage[main]/Networker/Service[networker]/enable: enable changed 'false' to 'true' 
      Notice: /Stage[main]/Xymon/Service[xymon]/enable: enable changed 'false' to 'true' 
      Notice: Applied catalog in 6.34 seconds
      

      Same with lines extracted from debug mode :

      Debug: Executing: '/usr/bin/systemctl is-active networker' 
      Debug: Executing: '/usr/bin/systemctl show networker --property LoadState --property UnitFileState --no-pager' 
      Debug: Executing: '/usr/bin/systemctl unmask networker' 
      Debug: Executing: '/usr/bin/systemctl enable networker' 
      Notice: /Stage[main]/Networker/Service[networker]/enable: enable changed 'false' to 'true' 
      Debug: /Stage[main]/Networker/Service[networker]: The container Class[Networker] will propagate my refresh event 
      ... 
      Debug: Executing: '/usr/bin/systemctl is-active xymon' 
      Debug: Executing: '/usr/bin/systemctl show xymon --property LoadState --property UnitFileState --no-pager' 
      Debug: Executing: '/usr/bin/systemctl unmask xymon' 
      Debug: Executing: '/usr/bin/systemctl enable xymon' 
      Notice: /Stage[main]/Xymon/Service[xymon]/enable: enable changed 'false' to 'true' 
      Debug: /Stage[main]/Xymon/Service[xymon]: The container Class[Xymon] will propagate my refresh event
      

      Workaround 1

      Setting provider => redhat on services that use init scripts instead of systemd units should work around the issue.

      Workaround 2

      Patched systemd.rb to be able to install the 4.2.1 agent on RHEL 7 nodes:

      # diff -u /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/systemd.rb.dist /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/systemd.rb 
      --- /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/systemd.rb.dist 2015-07-21 22:58:08.000000000 +0200 
      +++ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/service/systemd.rb 2015-09-18 11:08:19.789819128 +0200 
      @@ -63,6 +63,10 @@ 
      ret = debian_enabled?(svc_info) 
      return ret if ret 
      end 
      + if Facter.value(:osfamily) == 'RedHat' 
      + ret = redhat_enabled?(svc_info) 
      + return ret if ret 
      + end 
      rescue Puppet::ExecutionFailure 
      # The execution of the systemd command can fail for quite a few reasons. 
      # In all of these cases, the failure of the query indicates that the 
      @@ -95,6 +99,18 @@ 
      end 
      end
       
      + def redhat_enabled?(svc_info) 
      + # If UnitFileState == UnitFileState then we query the older way. 
      + if svc_info[:UnitFileState] == 'UnitFileState' 
      + begin 
      + systemctl("is-enabled", @resource[:name]) 
      + rescue Puppet::ExecutionFailure 
      + return :false 
      + end 
      + return :true 
      + end 
      + end 
      + 
      def status 
      begin 
      systemctl("is-active", @resource[:name])
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ali Ali Tukimin
              • Votes:
                8 Vote for this issue
                Watchers:
                16 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support