class Chef::Resource::Sudo
Public Instance Methods
after_created()
click to toggle source
handle legacy cookbook property
# File lib/chef/resource/sudo.rb, line 113 def after_created raise "The 'visudo_path' property from the sudo cookbook has been replaced with the 'visudo_binary' property. The path is now more intelligently determined and for most users specifying the path should no longer be necessary. If this resource still cannot determine the path to visudo then provide the full path to the binary with the 'visudo_binary' property." if visudo_path end
coerce_groups(x)
click to toggle source
make sure each group starts with a %
# File lib/chef/resource/sudo.rb, line 122 def coerce_groups(x) # split strings on the commas with optional spaces on either side groups = x.is_a?(Array) ? x : x.split(/\s*,\s*/) # make sure all the groups start with % groups.map { |g| g[0] == "%" ? g : "%#{g}" } end
platform_config_prefix()
click to toggle source
default config prefix paths based on platform @return [String]
# File lib/chef/resource/sudo.rb, line 132 def platform_config_prefix case node["platform_family"] when "smartos" "/opt/local/etc" when "mac_os_x" "/private/etc" when "freebsd" "/usr/local/etc" else "/etc" end end
validate_properties()
click to toggle source
Ensure that the inputs are valid (we cannot just use the resource for this)
# File lib/chef/resource/sudo.rb, line 216 def validate_properties # if group, user, env_keep_add, env_keep_subtract and template are nil, throw an exception raise "You must specify users, groups, env_keep_add, env_keep_subtract, or template properties!" if new_resource.users.empty? && new_resource.groups.empty? && new_resource.template.nil? && new_resource.env_keep_add.empty? && new_resource.env_keep_subtract.empty? # if specifying user or group and template at the same time fail raise "You cannot specify users or groups properties and also specify a template. To use your own template pass in all template variables using the variables property." if (!new_resource.users.empty? || !new_resource.groups.empty?) && !new_resource.template.nil? end
visudo_present?()
click to toggle source
# File lib/chef/resource/sudo.rb, line 224 def visudo_present? return true if ::File.exist?(new_resource.visudo_binary) Chef::Log.warn("The visudo binary cannot be found at '#{new_resource.visudo_binary}'. Skipping sudoer file validation. If visudo is on this system you can specify the path using the 'visudo_binary' property.") end