summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsnehaldwivedi <sdwivedi@msystechnologies.com>2021-11-08 21:19:01 -0800
committersnehaldwivedi <sdwivedi@msystechnologies.com>2021-11-08 21:19:01 -0800
commitf3e3f07ce70fa388f2eb2f95bfa22b3a7bde0c0e (patch)
treee2757a179752b8ffe684979ab07ca7d090fbb1be
parentf15d21260dcf7ad8052f80b0a8b73ad144a3ef77 (diff)
downloadchef-snehal/systemd_unit_fix.tar.gz
Changes for bad masked rspecsnehal/systemd_unit_fix
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
-rw-r--r--lib/chef/provider/systemd_unit.rb8
-rw-r--r--spec/unit/provider/systemd_unit_spec.rb3
2 files changed, 1 insertions, 10 deletions
diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb
index bba5307453..3ba05e6519 100644
--- a/lib/chef/provider/systemd_unit.rb
+++ b/lib/chef/provider/systemd_unit.rb
@@ -236,13 +236,7 @@ class Chef
def masked?
# Note: masked-runtime is excluded, because runtime is volatile, and
# because masked-runtime is not masked.
- # shell_out to get "masked" stdout.
- shell_out!("systemctl list-unit-files | grep masked").stdout.each_line do |line|
- if line.include?(new_resource.unit_name)
- return %w{bad masked}.include?(systemd_unit_status["UnitFileState"])
- end
- end
- false
+ %w{bad masked}.include?(systemd_unit_status["UnitFileState"])
end
def static?
diff --git a/spec/unit/provider/systemd_unit_spec.rb b/spec/unit/provider/systemd_unit_spec.rb
index faba0e6805..428a897751 100644
--- a/spec/unit/provider/systemd_unit_spec.rb
+++ b/spec/unit/provider/systemd_unit_spec.rb
@@ -929,9 +929,6 @@ describe Chef::Provider::SystemdUnit, :linux_only do
before(:each) do
provider.current_resource = current_resource
allow(provider).to receive(:which).with("systemctl").and_return(systemctl_path.to_s)
- allow(provider).to receive(:shell_out_compacted!).with("systemctl list-unit-files | grep masked").and_return(
- double(stdout: "sysstat-collect\\x2d.timer masked")
- )
end
masked_and_inactive = <<-STDOUT