#
# Cookbook:: irrigate-haproxy
# Recipe:: service
#
# Author:: Russell de Moose (<rdemoose@theorchard.com>)
# Copyright:: (C) The Orchard
#

haproxy_cluster_name = node['haproxy']['cluster_name']
haproxy_cookbook_file_path = "haproxy_#{haproxy_cluster_name}.cfg"
haproxy_config_file_path = node['haproxy']['config_file_path']

cookbook_file haproxy_config_file_path do
  source haproxy_cookbook_file_path
  backup 2
  owner 'root'
  group 'root'
  mode '0644'
  notifies :restart, 'service[haproxy]', :immediately
end

service 'haproxy' do
  supports restart: true, status: true, reload: false
  action [:enable, :start]
end
