if details[:status]
group_members = details[:members] || account["members"] || []
- user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name.to_s}"
+ user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name}"
manage_home = details[:manage_home] || account["manage_home"] || node[:accounts][:manage_home]
- groups = details[:groups] || account["groups"] || []
group_members = group_members.collect { |m| m.to_s }.sort
end
def enabled?
- ::File.exists?(enabled_name)
+ ::File.exist?(enabled_name)
end
owner "root"
group "root"
notifies :reload, "service[apache2]"
- only_if { ::File.exists?(available_name("conf")) }
+ only_if { ::File.exist?(available_name("conf")) }
end
new_resource.updated_by_last_action(true)
end
def installed?
- ::File.exists?(available_name("load"))
+ ::File.exist?(available_name("load"))
end
def enabled?
- ::File.exists?(enabled_name("load"))
+ ::File.exist?(enabled_name("load"))
end
end
def enabled?
- ::File.exists?(enabled_name)
+ ::File.exist?(enabled_name)
end
def edit_file(file, &block)
Chef::DelayedEvaluator.new do
::File.new(file).collect do |line|
- line = block.call(line)
+ block.call(line)
end.join("")
end
end
passwords = data_bag_item("civicrm", "passwords")
database_password = passwords["database"]
-admin_password = passwords["admin"]
site_key = passwords["key"]
mysql_user "civicrm@localhost" do
port = 7000 + account["uid"].to_i
if ["user","administrator"].include?(details[:status])
- user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name.to_s}"
+ user_home = details[:home] || account["home"] || "#{node[:accounts][:home]}/#{name}"
if File.directory?("#{user_home}/public_html")
template "/etc/php5/fpm/pool.d/#{name}.conf" do
template "apache.apis.erb"
end
- node[:postgresql][:clusters].each do |name,details|
+ node[:postgresql][:clusters].each_key do |name|
postgresql_munin name do
cluster name
database "ALL"
owner "root"
group "root"
mode 0644
- not_if do
- File.exists?("/etc/ssl/certs/exim.pem") and File.exists?("/etc/ssl/private/exim.key")
+ not_if do
+ File.exist?("/etc/ssl/certs/exim.pem") and File.exist?("/etc/ssl/private/exim.key")
end
end
user "root"
group "ssl-cert"
not_if do
- File.exists?("/etc/ssl/certs/exim.pem") and File.exists?("/etc/ssl/private/exim.key")
+ File.exist?("/etc/ssl/certs/exim.pem") and File.exist?("/etc/ssl/private/exim.key")
end
end
default[:hardware][:modules] |= [ "ipmi_devintf" ]
end
-if File.exists?("/proc/xen")
+if File.exist?("/proc/xen")
default[:hardware][:watchdog] = "xen_wdt"
elsif node[:kernel][:modules].include?("i6300esb")
default[:hardware][:watchdog] = "none"
end
end
-if File.exists?("/etc/mdadm/mdadm.conf")
+if File.exist?("/etc/mdadm/mdadm.conf")
mdadm_conf = edit_file "/etc/mdadm/mdadm.conf" do |line|
line.gsub!(/^MAILADDR .*$/, "MAILADDR admins@openstreetmap.org")
incrontabs = {}
-node[:incron].each do |name,details|
+node[:incron].each_value do |details|
user = details[:user]
path = details[:path]
mask = details[:events].join(",")
define :mediawiki_extension, :action => [ :enable ], :variables => {} do
name = params[:name]
site = params[:site]
- site_directory = node[:mediawiki][:sites][site][:site_directory]
mediawiki_directory = node[:mediawiki][:sites][site][:directory]
extension_directory = "#{mediawiki_directory}/extensions/#{name}"
source = params[:source]
user node[:mediawiki][:user]
group node[:mediawiki][:group]
not_if do
- File.exists?("#{mediawiki[:directory]}/LocalSettings-install.php")
+ File.exist?("#{mediawiki[:directory]}/LocalSettings-install.php")
end
notifies :create, 'ruby_block[rename-installer-localsettings]', :immediately
end
#
end
not_if do
- File.exists?("#{mediawiki[:directory]}/LocalSettings-install.php")
+ File.exist?("#{mediawiki[:directory]}/LocalSettings-install.php")
end
notifies :run, resources(:execute => "#{mediawiki[:directory]}/maintenance/install.php"), :immediately
action :create
def target_path
case
- when ::File.exists?(target)
+ when ::File.exist?(target)
target
- when ::File.exists?("/usr/local/share/munin/plugins/#{target}")
+ when ::File.exist?("/usr/local/share/munin/plugins/#{target}")
"/usr/local/share/munin/plugins/#{target}"
- when ::File.exists?("/usr/share/munin/plugins/#{target}")
+ when ::File.exist?("/usr/share/munin/plugins/#{target}")
"/usr/share/munin/plugins/#{target}"
else
nil
# apcpdu_
munin_plugin "cpu"
-if File.exists?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
+if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
munin_plugin "cpuspeed"
else
munin_plugin "cpuspeed" do
end
end
-disks = node[:block_device].select do |name,attributes|
+disks = node[:block_device].select do |_,attributes|
[ "ATA", "FUJITSU", "SEAGATE", "DELL", "COMPAQ", "IBM-ESXS" ].include?(attributes[:vendor])
end
end
end
-if File.exists?("/sbin/hpasmcli")
+if File.exist?("/sbin/hpasmcli")
munin_plugin "hpasmcli2_temp" do
target "hpasmcli2_"
end
sensors_volt = false
Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
- hwmon = "#{hwmon}/device" unless File.exists?("#{hwmon}/name")
+ hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
[@mysql.canonicalise_user(user), privileges]
end]
- @current_resource.permissions.each do |user,privileges|
+ @current_resource.permissions.each_key do |user|
unless new_permissions[user]
converge_by("revoke all for #{user} on #{new_resource}") do
Chef::Log.info("Revoking all for #{user} on #{new_resource}")
networking = construct_attributes[:networking] || {}
networking_interfaces = networking[:interfaces] || []
- networking_interfaces.each do |name,interface|
+ networking_interfaces.each_value do |interface|
if options[:role].nil? or interface[:role].to_s == options[:role].to_s
if options[:family].nil? or interface[:family].to_s == options[:family].to_s
if block.nil?
group "root"
mode 0755
recursive true
- not_if { File.exists?(mountpoint) }
+ not_if { File.exist?(mountpoint) }
end
mount mountpoint do
execute "php-pear-db" do
command "pear install DB"
- not_if { File.exists?("/usr/share/php/DB") }
+ not_if { File.exist?("/usr/share/php/DB") }
end
execute "compile_nominatim" do
creates "/etc/openvpn/#{name}.key"
end
- if File.exists?("/etc/openvpn/#{name}.key")
+ if File.exist?("/etc/openvpn/#{name}.key")
node.set[:openvpn][:keys][name] = IO.read("/etc/openvpn/#{name}.key")
end
elsif peer and peer[:openvpn]
node[:osqa][:sites].each do |site|
name = site[:name]
directory = site[:directory] || "/srv/#{name}"
- osqa_revision = site[:revision] || node[:osqa][:revision]
site_user = site[:user] || node[:osqa][:user]
site_user = Etc.getpwuid(site_user).name if site_user.is_a?(Integer)
site_group = site[:group] || node[:osqa][:group] || Etc.getpwnam(site_user).gid
version = node[:otrs][:version]
user = node[:otrs][:user]
-group = node[:otrs][:group]
database_cluster = node[:otrs][:database_cluster]
database_name = node[:otrs][:database_name]
database_user = node[:otrs][:database_user]
end
end
- @current_resource.permissions.each do |user,privileges|
+ @current_resource.permissions.each_key do |user|
unless new_resource.permissions[user]
converge_by("revoke all for #{user} on #{new_resource}") do
Chef::Log.info("Revoking all for #{user} on #{new_resource}")
file sysctl_file do
content "#{value}\n"
atomic_update false
- only_if { File.exists?(sysctl_file) }
+ only_if { File.exist?(sysctl_file) }
end
end
end
file sysfs_file do
content "#{value}\n"
atomic_update false
- only_if { File.exists?(sysfs_file) }
+ only_if { File.exist?(sysfs_file) }
end
end
end
end
end
- def Expire.do_expire(change_file, min_zoom, max_zoom, &block)
+ def Expire.do_expire(change_file, min_zoom, max_zoom, &_)
# read in the osm change file
doc = XML::Document.file(change_file)
set = Set.new nodes.values
# expire tiles and shrink to the set of parents
- (max_zoom).downto(min_zoom) do |z|
+ (max_zoom).downto(min_zoom) do |_|
# allow the block to work on the set, returning the set at the next
# zoom level
set = yield set
mode 0755
end
-node[:tile][:data].each do |name,data|
+node[:tile][:data].each_value do |data|
url = data[:url]
file = "/srv/tile.openstreetmap.org/data/#{File.basename(url)}"
directory = "/srv/tile.openstreetmap.org/data/#{data[:directory]}"
mode 0755
end
-tile_directories = node[:tile][:styles].collect do |name,style|
+tile_directories = node[:tile][:styles].collect do |_,style|
style[:tile_directories].collect { |directory| directory[:name] }
end.flatten.sort.uniq
command "trac-admin /var/lib/trac deploy #{site_directory}"
user "root"
group "root"
- not_if { File.exists?(site_directory) }
+ not_if { File.exist?(site_directory) }
end
cookbook_file "/usr/local/bin/trac-authenticate" do
rails_directory = "#{node[:web][:base_directory]}/rails"
-piwik_configuration = data_bag_item("web", "piwik").to_hash.reject do |k,v|
+piwik_configuration = data_bag_item("web", "piwik").to_hash.reject do |k,_|
["chef_type", "data_bag", "id"].include?(k)
end