diff options
author | Nathan Williams <nath.e.will@gmail.com> | 2018-02-07 23:09:51 -0800 |
---|---|---|
committer | Nathan Williams <nath.e.will@gmail.com> | 2018-02-07 23:14:36 -0800 |
commit | eecc7f1b297fd610ae9217b48baa0b05ccafaaf4 (patch) | |
tree | 055dbff45761629c93d9c02092ceb21b76a24b56 /lib | |
parent | 051b99d77cefe42d0a7c1f56ec9dc2c60f3f4b84 (diff) | |
download | chef-eecc7f1b297fd610ae9217b48baa0b05ccafaaf4.tar.gz |
add additional systemd unit actions
Signed-off-by: Nathan Williams <nath.e.will@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/systemd_unit.rb | 20 | ||||
-rw-r--r-- | lib/chef/resource/systemd_unit.rb | 5 |
2 files changed, 22 insertions, 3 deletions
diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb index e1853bd984..5a338d2e2e 100644 --- a/lib/chef/provider/systemd_unit.rb +++ b/lib/chef/provider/systemd_unit.rb @@ -1,6 +1,6 @@ # # Author:: Nathan Williams (<nath.e.will@gmail.com>) -# Copyright:: Copyright 2016, Nathan Williams +# Copyright:: Copyright 2016-2018, Nathan Williams # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -74,6 +74,18 @@ class Chef end end + def action_preset + converge_by("restoring enable/disable preset configuration for unit: #{new_resource.unit_name}") do + systemctl_execute!(:preset, new_resource.unit_name) + end + end + + def action_revert + converge_by("reverting to vendor version of unit: #{new_resource.unit_name}") do + systemctl_execute!(:revert, new_resource.unit_name) + end + end + def action_enable if current_resource.static Chef::Log.debug("#{new_resource.unit_name} is a static unit, enabling is a NOP.") @@ -98,6 +110,12 @@ class Chef end end + def action_reenable + converge_by("reenabling unit: #{new_resource.unit_name}") do + systemctl_execute!(:reenable, new_resource.unit_name) + end + end + def action_mask unless current_resource.masked converge_by("masking unit: #{new_resource.unit_name}") do diff --git a/lib/chef/resource/systemd_unit.rb b/lib/chef/resource/systemd_unit.rb index b08b26efa7..baf7e4cfa8 100644 --- a/lib/chef/resource/systemd_unit.rb +++ b/lib/chef/resource/systemd_unit.rb @@ -1,6 +1,6 @@ # # Author:: Nathan Williams (<nath.e.will@gmail.com>) -# Copyright:: Copyright 2016, Nathan Williams +# Copyright:: Copyright 2016-2018, Nathan Williams # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,7 +29,8 @@ class Chef default_action :nothing allowed_actions :create, :delete, - :enable, :disable, + :preset, :revert, + :enable, :disable, :reenable, :mask, :unmask, :start, :stop, :restart, :reload, |