Puppet Function: pick_initscript
- Defined in:
- modules/base/lib/puppet/parser/functions/pick_initscript.rb
- Function type:
- Ruby 3.x API
Overview
Takes as an input the init system currently installed, the available init scripts, and returns the chosen one.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'modules/base/lib/puppet/parser/functions/pick_initscript.rb', line 3 Puppet::Parser::Functions.newfunction(:pick_initscript, :type => :rvalue, :arity => 7, :doc => <<-'HEREDOC' Takes as an input the init system currently installed, the available init scripts, and returns the chosen one. HEREDOC ) do |vals| name, init_system, has_systemd, has_systemd_override, has_upstart, has_sysvinit, strict = vals has_custom = (has_systemd || has_upstart || has_sysvinit) # if we don't have custom scripts, we use the system defaults return false unless has_custom case init_system when 'systemd' return 'systemd_override' if has_systemd_override return 'systemd' if has_systemd return 'sysvinit' if has_sysvinit return false unless strict raise(ArgumentError, "Service unit #{name} has an upstart script but nothing useful for systemd") when 'upstart' return 'upstart' if has_upstart return 'sysvinit' if has_sysvinit return false unless strict raise(ArgumentError, "Service unit #{name} has a systemd script but nothing useful for upstart") when 'sysvinit' return 'sysvinit' if has_sysvinit return false unless strict raise(ArgumentError, 'Service unit #{name} lacks a custom sysvinit script') else raise(ArgumentError, 'Unsupported init system') end end |