Jira (PUP-10974) service enable=mask fails when service isn't present

1 view
Skip to first unread message

Steven Pritchard (Jira)

unread,
Mar 25, 2021, 2:21:05 PM3/25/21
to puppe...@googlegroups.com
Steven Pritchard created an issue
 
Puppet / Bug PUP-10974
service enable=mask fails when service isn't present
Issue Type: Bug Bug
Affects Versions: PUP 7.5.0
Assignee: Unassigned
Components: Types and Providers
Created: 2021/03/25 11:20 AM
Priority: Normal Normal
Reporter: Steven Pritchard

Puppet Version: 6.21.1, 7.5.0
Puppet Server Version: N/A
OS Name/Version: CentOS 7

With the systemd provider, setting enable to mask on a service that does not exist fails.

Desired Behavior:

Masking a service should work whether or not the service exists (the way that setting enable to false works either way).

Actual Behavior:

[root@puppet ~]# systemctl list-unit-files | grep madeup
[root@puppet ~]# puppet resource service madeup
service { 'madeup':
 ensure => 'stopped',
 enable => 'false',
 provider => 'systemd',
}
[root@puppet ~]# puppet resource service madeup enable=mask
Error: Could not disable madeup: 
Error: /Service[madeup]/enable: change from 'false' to 'mask' failed: Could not disable madeup: 
service { 'madeup':
 enable => 'false',
 provider => 'systemd',
}
[root@puppet ~]# systemctl mask madeup
Created symlink from /etc/systemd/system/madeup.service to /dev/null.
[root@puppet ~]# systemctl list-unit-files | grep madeup
madeup.service masked

The error here appears to be coming from https://github.com/puppetlabs/puppet/blob/85bd9ed07e3e6c956f1972624a50be914292e1ab/lib/puppet/provider/service/systemd.rb#L162.  If I wrap that in a begin block, the service is masked properly.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Mihai Buzgau (Jira)

unread,
Mar 26, 2021, 2:50:04 AM3/26/21
to puppe...@googlegroups.com

Steven Pritchard (Jira)

unread,
May 4, 2021, 4:52:05 PM5/4/21
to puppe...@googlegroups.com
Steven Pritchard commented on Bug PUP-10974
 
Re: service enable=mask fails when service isn't present

I think if someone looks at this, it will be an easy fix...  It might be as simple as this:

diff --git a/lib/puppet/provider/service/systemd.rb b/lib/puppet/provider/service/systemd.rb
index d0bfb85e5a..b0601c7506 100644
--- a/lib/puppet/provider/service/systemd.rb
+++ b/lib/puppet/provider/service/systemd.rb
@@ -159,7 +159,10 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
   end
 
   def mask
-    self.disable
+    begin
+      self.disable
+    rescue
+    end
     systemctl_change_enable(:mask)
   end
 

This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Steven Pritchard (Jira)

unread,
Jun 7, 2021, 5:09:03 PM6/7/21
to puppe...@googlegroups.com

Bug still present on 6.22.1 and 7.7.0.

Josh Cooper (Jira)

unread,
Jun 8, 2021, 1:09:01 PM6/8/21
to puppe...@googlegroups.com

Steven Pritchard (Jira)

unread,
Jun 8, 2021, 1:10:02 PM6/8/21
to puppe...@googlegroups.com
 
Re: service enable=mask fails when service isn't present

This is required for compliance enforcement.  Various CIS controls require services to be masked, whether or not they are installed.

Josh Cooper (Jira)

unread,
Jun 8, 2021, 2:22:01 PM6/8/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jun 8, 2021, 2:22:02 PM6/8/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Night's Watch Coremunity

Josh Cooper (Jira)

unread,
Jun 8, 2021, 2:22:02 PM6/8/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Platform Core KANBAN

Gabriel Nagy (Jira)

unread,
Jun 9, 2021, 3:55:02 AM6/9/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Jun 9, 2021, 3:57:02 AM6/9/21
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
 
Change By: Gabriel Nagy
Fix Version/s: PUP 7.8.0
Fix Version/s: PUP 6.23.0

Josh Cooper (Jira)

unread,
Jun 9, 2021, 5:27:02 PM6/9/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Bug Fix
Release Notes Summary: It's now possible to mask a systemd service that doesn't (yet) exist.

Christine Yoon (Jira)

unread,
Jun 21, 2021, 12:43:01 PM6/21/21
to puppe...@googlegroups.com
Christine Yoon updated an issue
Change By: Christine Yoon
Labels: community doc_reviewed

Christine Yoon (Jira)

unread,
Jun 21, 2021, 2:28:03 PM6/21/21
to puppe...@googlegroups.com
Christine Yoon updated an issue
Change By: Christine Yoon
Labels: community doc_reviewed doc-reviewed

Christine Yoon (Jira)

unread,
Jun 21, 2021, 4:01:02 PM6/21/21
to puppe...@googlegroups.com
Christine Yoon updated an issue
Change By: Christine Yoon
Labels: community doc docs -reviewed
Reply all
Reply to author
Forward
0 new messages