diff --git a/attributes/default.rb b/attributes/default.rb index ceade1f..1a8b081 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -2,4 +2,4 @@ default[:mon_notification][:user] = 'mon-notification' default[:mon_notification][:group] = 'mon-notification' default[:mon_notification][:conf_dir] = '/etc/mon' default[:mon_notification][:log_dir] = '/var/log/mon-notification' -default[:mon_notification][:smtp_server] = 'localhost' +default[:mon_notification][:data_bag] = 'mon_notification' diff --git a/metadata.rb b/metadata.rb index 19ae034..3f86697 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,4 +4,4 @@ maintainer_email 'hpcs-mon@hp.com' license 'All rights reserved' description 'Installs/Configures mon_notification' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.1.8' +version '0.1.9' diff --git a/recipes/default.rb b/recipes/default.rb index e6e2d89..295949a 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -43,12 +43,16 @@ directory node[:mon_notification][:log_dir] do mode 0775 end -# todo - setup a data bag for the config details and an encrypted one for credentials +# todo - setup an encrypted data bag for credentials +hosts = data_bag_item(node[:mon_notification][:data_bag], 'hosts') template "#{node[:mon_notification][:conf_dir]}/notification.yaml" do action :create source 'notification.yaml.erb' owner 'root' group node[:mon_notification][:group] mode 0640 + variables( + :hosts => hosts + ) notifies :restart, "service[mon-notification]" end diff --git a/templates/default/notification.yaml.erb b/templates/default/notification.yaml.erb index e1788b8..328f587 100644 --- a/templates/default/notification.yaml.erb +++ b/templates/default/notification.yaml.erb @@ -1,17 +1,17 @@ kafka: - url: 192.168.10.10:9092 + url: <%= @hosts['kafka'] %>:9092 group: <%= node[:mon_notification][:group] %> alarm_topic: alarm-state-transitions notification_topic: alarm-notifications mysql: - host: 192.168.10.6 + host: <%= @hosts['mysql'] %> user: notification passwd: password db: mon email: - server: <%= node[:mon_notification][:smtp_server] %> + server: <%= @hosts['smtp'] %> port: 25 user: password: @@ -32,7 +32,7 @@ queues: sent_notifications_size: 50 # limiting this size reduces potential # of re-sent notifications after a failure zookeeper: - url: 192.168.10.10:2181 + url: <%= @hosts['zookeeper'] %>:2181 max_offset_lag: 600 # In seconds, undefined for none logging: # Used in logging.dictConfig