diff --git a/libraries/zookeeper_config.rb b/libraries/zookeeper_config.rb index 78b806b..0759860 100644 --- a/libraries/zookeeper_config.rb +++ b/libraries/zookeeper_config.rb @@ -26,6 +26,8 @@ class ZookeeperConfig < Chef::Resource attribute(:group, kind_of: String, default: 'zookeeper') attribute(:instance_name, kind_of: String, required: true) + attribute(:instance_id, kind_of: String, default: lazy { ensemble.index(instance_name).next.to_s }) + alias_method :myid, :instance_id attribute(:data_dir, kind_of: String, default: '/var/lib/zookeeper') attribute(:client_port, kind_of: Integer, default: 2181) attribute(:leader_port, kind_of: Integer, default: 2888) @@ -33,10 +35,6 @@ class ZookeeperConfig < Chef::Resource attribute(:ensemble, kind_of: Array, default: [], required: true) attribute(:properties, option_collector: true, default: {}) - def myid - ensemble.index(instance_name).next.to_s - end - # Outputs the +properties+ in the Java Properties file format. This is # what Zookeeper daemon consumes to tweak its internal configuration. def to_s @@ -67,9 +65,22 @@ def to_s mode '0644' end - file new_resource.path do + # create zoo.properties.static file and only update + # zoo.properties when static file has changed. + # this is needed to ensure chef won't constantly update + # zoo.properties and force restarts of zookeeper when + # it dynamically updates zoo.properties. + file new_resource.path+".static" do + content new_resource.to_s + mode '0644' + notifies :create, 'file[config_base]', :immediately + end + + file 'config_base' do content new_resource.to_s + path new_resource.path mode '0644' + action :nothing end end end diff --git a/metadata.rb b/metadata.rb index 0a8decc..010a7ea 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache 2.0' description 'Application cookbook which installs and configures a Zookeeper cluster.' long_description 'Application cookbook which installs and configures a Zookeeper cluster.' -version '1.3.2' +version '1.3.4' supports 'ubuntu', '>= 12.04' supports 'centos', '>= 6.6'