3 # Resource:: systemd_socket
 
   5 # Copyright:: 2021, 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.
 
  22 default_action :create
 
  24 property :socket, String, :name_property => true
 
  25 property :description, String, :required => [:create]
 
  26 property :after, [String, Array]
 
  27 property :wants, [String, Array]
 
  28 property :listen_stream, [String, Array]
 
  29 property :listen_datagram, [String, Array]
 
  30 property :listen_sequential_packet, [String, Array]
 
  31 property :listen_fifo, [String, Array]
 
  32 property :listen_special, [String, Array]
 
  33 property :listen_netlink, [String, Array]
 
  34 property :listen_message_queue, [String, Array]
 
  35 property :listen_usb_function, [String, Array]
 
  36 property :socket_protocol, String
 
  37 property :bind_ipv6_only, String
 
  38 property :backlog, Integer
 
  39 property :bind_to_device, String
 
  40 property :socket_user, String
 
  41 property :socket_group, String
 
  42 property :socket_mode, Integer
 
  43 property :directory_mode, Integer
 
  44 property :accept, [true, false]
 
  45 property :writable, [true, false]
 
  46 property :max_connections, Integer
 
  47 property :max_connections_per_source, Integer
 
  48 property :keep_alive, [true, false]
 
  49 property :keep_alive_time_sec, Integer
 
  50 property :keep_alive_interval_sec, Integer
 
  51 property :keep_alive_probes, Integer
 
  52 property :no_delay, [true, false]
 
  53 property :priority, Integer
 
  54 property :defer_accept_sec, Integer
 
  55 property :receive_buffer, Integer
 
  56 property :send_buffer, Integer
 
  57 property :ip_tos, Integer
 
  58 property :ip_ttl, Integer
 
  59 property :mark, Integer
 
  60 property :reuse_port, [true, false]
 
  61 property :pipe_size, Integer
 
  62 property :message_queue_max_messages, Integer
 
  63 property :message_queue_message_size, Integer
 
  64 property :free_bind, [true, false]
 
  65 property :transparent, [true, false]
 
  66 property :broadcast, [true, false]
 
  67 property :pass_credentials, [true, false]
 
  68 property :pass_security, [true, false]
 
  69 property :tcp_congestion, String
 
  70 property :exec_start_pre, [String, Array]
 
  71 property :exec_start, [String, Array]
 
  72 property :exec_start_post, [String, Array]
 
  73 property :exec_stop, [String, Array]
 
  74 property :timeout_sec, [Integer, String]
 
  75 property :service, String
 
  76 property :remove_on_stop, [true, false]
 
  77 property :symlinks, [String, Array]
 
  78 property :file_descriptor_name, String
 
  79 property :trigger_limit_interval_sec, [Integer, String]
 
  80 property :trigger_limit_burst, Integer
 
  83   socket_variables = new_resource.to_hash
 
  85   template "/etc/systemd/system/#{new_resource.socket}.socket" do
 
  91     variables socket_variables
 
  94   execute "systemctl-reload-#{new_resource.socket}.socket" do
 
  96     command "systemctl daemon-reload"
 
  99     subscribes :run, "template[/etc/systemd/system/#{new_resource.socket}.socket]"
 
 104   file "/etc/systemd/system/#{new_resource.socket}.socket" do
 
 108   execute "systemctl-reload-#{new_resource.socket}.socket" do
 
 110     command "systemctl daemon-reload"
 
 113     subscribes :run, "file[/etc/systemd/system/#{new_resource.socket}.socket]"