Skip to content

Commit

Permalink
Add sane defaults for nil address or port attributes
Browse files Browse the repository at this point in the history
- Sets the address to * if not specified in attributes
- Sets the ports to 80 & 443 if not specifid in attributes
  • Loading branch information
brentm5 committed Apr 19, 2016
1 parent 7af0eaa commit 70a26c2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libraries/listen.rb
Expand Up @@ -34,8 +34,9 @@ def self.converted_listen_ports_and_addresses(node)
return [] unless node['apache']['listen_ports'] || node['apache']['listen_addresses']
Chef::Log.warn "node['apache']['listen_ports'] and node['apache']['listen_addresses'] are deprecated in favor of node['apache']['listen']. Please adjust your cookbooks"

(node['apache']['listen_addresses'] || []).uniq.each_with_object([]) do |address, listen|
(node['apache']['listen_ports'] || []).uniq.each do |port|
# Defaults to * for addresses or 80 / 443 for ports if not specified
(node['apache']['listen_addresses'] || %w(*)).uniq.each_with_object([]) do |address, listen|
(node['apache']['listen_ports'] || %w(80 443)).uniq.each do |port|
listen << "#{address}:#{port}"
end
end
Expand Down

0 comments on commit 70a26c2

Please sign in to comment.