Update cookbooks and add wordpress cookbook
This commit is contained in:
@@ -26,12 +26,12 @@ def whyrun_supported?
|
||||
end
|
||||
|
||||
# Ensure that the inputs are valid (we cannot just use the resource for this)
|
||||
def check_inputs(user, group, foreign_template, foreign_vars)
|
||||
def check_inputs(user, group, foreign_template, _foreign_vars)
|
||||
# if group, user, and template are nil, throw an exception
|
||||
if user.nil? && group.nil? && foreign_template.nil?
|
||||
fail 'You must provide a user, group, or template!'
|
||||
raise 'You must provide a user, group, or template!'
|
||||
elsif !user.nil? && !group.nil? && !template.nil?
|
||||
fail 'You cannot specify user, group, and template!'
|
||||
raise 'You cannot specify user, group, and template!'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -66,31 +66,34 @@ def render_sudoer
|
||||
if new_resource.template
|
||||
Chef::Log.debug('Template attribute provided, all other attributes ignored.')
|
||||
|
||||
resource = template "#{node['authorization']['sudo']['prefix']}/sudoers.d/#{new_resource.name}" do
|
||||
source new_resource.template
|
||||
owner 'root'
|
||||
group node['root_group']
|
||||
mode '0440'
|
||||
variables new_resource.variables
|
||||
action :nothing
|
||||
resource = template "#{node['authorization']['sudo']['prefix']}/sudoers.d/#{sudo_filename}" do
|
||||
source new_resource.template
|
||||
owner 'root'
|
||||
group node['root_group']
|
||||
mode '0440'
|
||||
variables new_resource.variables
|
||||
action :nothing
|
||||
end
|
||||
else
|
||||
sudoer = new_resource.user || "%#{new_resource.group}".squeeze('%')
|
||||
|
||||
resource = template "#{node['authorization']['sudo']['prefix']}/sudoers.d/#{new_resource.name}" do
|
||||
source 'sudoer.erb'
|
||||
cookbook 'sudo'
|
||||
owner 'root'
|
||||
group node['root_group']
|
||||
mode '0440'
|
||||
variables :sudoer => sudoer,
|
||||
:host => new_resource.host,
|
||||
:runas => new_resource.runas,
|
||||
:nopasswd => new_resource.nopasswd,
|
||||
:commands => new_resource.commands,
|
||||
:command_aliases => new_resource.command_aliases,
|
||||
:defaults => new_resource.defaults
|
||||
action :nothing
|
||||
resource = template "#{node['authorization']['sudo']['prefix']}/sudoers.d/#{sudo_filename}" do
|
||||
source 'sudoer.erb'
|
||||
cookbook 'sudo'
|
||||
owner 'root'
|
||||
group node['root_group']
|
||||
mode '0440'
|
||||
variables sudoer: sudoer,
|
||||
host: new_resource.host,
|
||||
runas: new_resource.runas,
|
||||
nopasswd: new_resource.nopasswd,
|
||||
commands: new_resource.commands,
|
||||
command_aliases: new_resource.command_aliases,
|
||||
defaults: new_resource.defaults,
|
||||
setenv: new_resource.setenv,
|
||||
env_keep_add: new_resource.env_keep_add,
|
||||
env_keep_subtract: new_resource.env_keep_subtract
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
|
||||
@@ -107,7 +110,7 @@ end
|
||||
action :install do
|
||||
target = "#{node['authorization']['sudo']['prefix']}/sudoers.d/"
|
||||
|
||||
unless ::File.exists?(target)
|
||||
unless ::File.exist?(target)
|
||||
sudoers_dir = directory target
|
||||
sudoers_dir.run_action(:create)
|
||||
end
|
||||
@@ -126,6 +129,12 @@ end
|
||||
|
||||
private
|
||||
|
||||
# acording to the sudo man pages sudo will ignore files in an include dir that have a `.` or `~`
|
||||
# It is quite common for users to have a `.` in their login, so we will convert this to `__`
|
||||
def sudo_filename
|
||||
new_resource.name.gsub(/\./, '__')
|
||||
end
|
||||
|
||||
# Capture a template to a string
|
||||
def capture(template)
|
||||
context = {}
|
||||
|
||||
Reference in New Issue
Block a user