Skip to content

Commit

Permalink
FC001 - strings instead of symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimberman committed Oct 11, 2012
1 parent 51e556c commit 8f04785
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 43 deletions.
24 changes: 12 additions & 12 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
default[:keepalived][:shared_address] = false
default[:keepalived][:global][:notification_emails] = 'admin@example.com'
default[:keepalived][:global][:notification_email_from] = "keepalived@#{node.domain || 'example.com'}"
default[:keepalived][:global][:smtp_server] = '127.0.0.1'
default[:keepalived][:global][:smtp_connect_timeout] = 30
default[:keepalived][:global][:router_id] = 'DEFAULT_ROUT_ID'
default[:keepalived][:global][:router_ids] = {} # node name based mapping
default[:keepalived][:check_scripts] = {}
default[:keepalived][:instance_defaults][:state] = 'MASTER'
default[:keepalived][:instance_defaults][:priority] = 100
default[:keepalived][:instance_defaults][:virtual_router_id] = 10
default[:keepalived][:instances] = {}
default['keepalived']['shared_address'] = false
default['keepalived']['global']['notification_emails'] = 'admin@example.com'
default['keepalived']['global']['notification_email_from'] = "keepalived@#{node['domain'] || 'example.com'}"
default['keepalived']['global']['smtp_server'] = '127.0.0.1'
default['keepalived']['global']['smtp_connect_timeout'] = 30
default['keepalived']['global']['router_id'] = 'DEFAULT_ROUT_ID'
default['keepalived']['global']['router_ids'] = {} # node name based mapping
default['keepalived']['check_scripts'] = {}
default['keepalived']['instance_defaults']['state'] = 'MASTER'
default['keepalived']['instance_defaults']['priority'] = 100
default['keepalived']['instance_defaults']['virtual_router_id'] = 10
default['keepalived']['instances'] = {}
8 changes: 3 additions & 5 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
# limitations under the License.
#

package "keepalived" do
action :install
end
package "keepalived"

if(node[:keepalived][:shared_address])
if node['keepalived']['shared_address']
file '/etc/sysctl.d/60-ip-nonlocal-bind.conf' do
mode 0644
content "net.ipv4.ip_nonlocal_bind=1\n"
Expand All @@ -42,5 +40,5 @@
service "keepalived" do
supports :restart => true
action [:enable, :start]
subscribes :restart, resources(:template => "/etc/keepalived/keepalived.conf"), :delayed
subscribes :restart, "template[/etc/keepalived/keepalived.conf"
end
52 changes: 26 additions & 26 deletions templates/default/keepalived.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,55 @@
! Generated by Chef.
global_defs {
notification_email {
<% Array(node[:keepalived][:global][:notification_emails]).each do |email| %>
<% Array(node['keepalived']['global']['notification_emails']).each do |email| %>
<%= email %>
<% end %>
}
notification_email_from <%= node[:keepalived][:global][:notification_email_from] %>
smtp_server <%= node[:keepalived][:global][:smtp_server] %>
smtp_connect_timeout <%= node[:keepalived][:global][:smtp_connect_timeout] %>
router_id <%= node[:keepalived][:global][:router_ids][node.name] || node[:keepalived][:global][:router_id] %>
notification_email_from <%= node['keepalived']['global']['notification_email_from'] %>
smtp_server <%= node['keepalived']['global']['smtp_server'] %>
smtp_connect_timeout <%= node['keepalived']['global']['smtp_connect_timeout'] %>
router_id <%= node['keepalived']['global']['router_ids'][node.name] || node['keepalived']['global']['router_id'] %>
}

<% node[:keepalived][:check_scripts].each_pair do |name, script| %>
<% node['keepalived']['check_scripts'].each_pair do |name, script| %>
vrrp_script <%= name %> {
script "<%= script[:script] %>"
interval <%= script[:interval] %>
weight <%= script[:weight] %>
script "<%= script['script'] %>"
interval <%= script['interval'] %>
weight <%= script['weight'] %>
}
<% end %>
<% node[:keepalived][:instances].each_pair do |name, instance| -%>
<% node['keepalived']['instances'].each_pair do |name, instance| -%>
<%
instance[:states] ||= {}
instance[:priorities] ||= {}
instance[:virtual_router_ids] ||= {}
instance['states'] ||= {}
instance['priorities'] ||= {}
instance['virtual_router_ids'] ||= {}
-%>
vrrp_instance <%= name.upcase %> {
interface <%= instance[:interface] %>
virtual_router_id <%= instance[:virtual_router_ids][node.name] || node[:keepalived][:instance_defaults][:virtual_router_id] %>
<% if instance[:nopreempt] -%>
interface <%= instance['interface'] %>
virtual_router_id <%= instance['virtual_router_ids'][node.name] || node['keepalived']['instance_defaults']['virtual_router_id'] %>
<% if instance['nopreempt'] -%>
nopreempt
<% end -%>
state <%= instance[:states][node.name] || node[:keepalived][:instance_defaults][:state] %>
priority <%= instance[:priorities][node.name] || node[:keepalived][:instance_defaults][:priority] %>
<% if instance[:advert_int] -%>
advert_int <%= instance[:advert_int] %>
state <%= instance['states'][node.name] || node['keepalived']['instance_defaults']['state'] %>
priority <%= instance['priorities'][node.name] || node['keepalived']['instance_defaults']['priority'] %>
<% if instance['advert_int'] -%>
advert_int <%= instance['advert_int'] %>
<% end -%>
<% if instance[:auth_type] -%>
<% if instance['auth_type'] -%>
authentication {
auth_type <%= instance[:auth_type].to_s.upcase %>
auth_pass <%= instance[:auth_pass] %>
auth_type <%= instance['auth_type'].to_s.upcase %>
auth_pass <%= instance['auth_pass'] %>
}
<% end -%>
virtual_ipaddress {
<% Array(instance[:ip_addresses]).each do |address| %>
<% Array(instance['ip_addresses']).each do |address| %>
<%= address %>
<% end %>
}
<% if instance[:track_script] %>
<% if instance['track_script'] %>
track_script {
<%= instance[:track_script] %>
<%= instance['track_script'] %>
}
<% end %>
}
Expand Down

0 comments on commit 8f04785

Please sign in to comment.