Skip to content
This repository was archived by the owner on Jun 13, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions libraries/zookeeper_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ 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)
attribute(:election_port, kind_of: Integer, default: 3888)
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
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the file continually updating? This mechanism won't change that it just makes it more obfuscated.

content new_resource.to_s
mode '0644'
notifies :create, 'file[config_base]', :immediately
end

file 'config_base' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you creating a file called config_base?

content new_resource.to_s
path new_resource.path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah missed that, nevermind.

mode '0644'
action :nothing
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down