3 # Resource:: systemd_timer
 
   5 # Copyright:: 2019, OpenStreetMap Foundation
 
   7 # Licensed under the Apache License, Version 2.0 (the "License");
 
   8 # you may not use this file except in compliance with the License.
 
   9 # You may obtain a copy of the License at
 
  11 # https://www.apache.org/licenses/LICENSE-2.0
 
  13 # Unless required by applicable law or agreed to in writing, software
 
  14 # distributed under the License is distributed on an "AS IS" BASIS,
 
  15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16 # See the License for the specific language governing permissions and
 
  17 # limitations under the License.
 
  20 default_action :create
 
  22 property :timer, String, :name_property => true
 
  23 property :description, String, :required => [:create]
 
  24 property :after, [String, Array]
 
  25 property :wants, [String, Array]
 
  26 property :on_active_sec, [Integer, String]
 
  27 property :on_boot_sec, [Integer, String]
 
  28 property :on_startup_sec, [Integer, String]
 
  29 property :on_unit_active_sec, [Integer, String]
 
  30 property :on_unit_inactive_sec, [Integer, String]
 
  31 property :on_calendar, String
 
  32 property :accuracy_sec, [Integer, String]
 
  33 property :randomized_delay_sec, [Integer, String]
 
  34 property :unit, String
 
  35 property :persistent, [true, false]
 
  36 property :wake_system, [true, false]
 
  37 property :remain_after_elapse, [true, false]
 
  40   timer_variables = new_resource.to_hash
 
  42   template "/etc/systemd/system/#{new_resource.timer}.timer" do
 
  48     variables timer_variables
 
  51   execute "systemctl-reload-#{new_resource.timer}.timer" do
 
  53     command "systemctl daemon-reload"
 
  56     subscribes :run, "template[/etc/systemd/system/#{new_resource.timer}.timer]"
 
  61   file "/etc/systemd/system/#{new_resource.timer}.timer" do
 
  65   execute "systemctl-reload-#{new_resource.timer}.timer" do
 
  67     command "systemctl daemon-reload"
 
  70     subscribes :run, "file[/etc/systemd/system/#{new_resource.timer}.timer]"