-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
387 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Provider::ConsulClient < Chef::Provider::LWRPBase | ||
use_inline_resources if defined?(use_inline_resources) | ||
|
||
def whyrun_supported? | ||
true | ||
end | ||
|
||
action :create do | ||
end | ||
|
||
action :delete do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Provider::ConsulClientBinary < Chef::Provider::ConsulClient | ||
action :create do | ||
include_recipe 'libarchive::default' | ||
|
||
archive = remote_file "#{Chef::Config[:file_cache_path]}/consul-#{new_resource.version}.zip" do | ||
source new_resource.url | ||
checksum new_resource.checksum | ||
end | ||
|
||
libarchive_file ::File.basename(archive.path) do | ||
path archive.path | ||
extract_to new_resource.path | ||
extract_options :no_overwrite | ||
action :extract | ||
end | ||
|
||
directory ::Dir.dirname(new_resource.filename) do | ||
recursive true | ||
owner 'root' | ||
group 'root' | ||
mode '00755' | ||
end | ||
|
||
link ::File.join(new_resource.path, 'consul') do | ||
to new_resource.filename | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Provider::ConsulServiceSource < Chef::Provider::ConsulService | ||
action :create do | ||
include_recipe 'golang::default' | ||
|
||
directory new_resource.path do | ||
recursive true | ||
owner 'root' | ||
group 'root' | ||
mode '00755' | ||
end | ||
|
||
git new_resource.path do | ||
repository new_resource.url | ||
reference new_resource.version | ||
action :checkout | ||
end | ||
|
||
golang_package 'github.com/hashicorp/consul' do | ||
action :install | ||
end | ||
|
||
directory ::Dir.dirname(new_resource.filename) do | ||
recursive true | ||
owner 'root' | ||
group 'root' | ||
mode '00755' | ||
end | ||
|
||
link ::File.join(new_resource.path, 'consul') do | ||
to new_resource.filename | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Provider::ConsulConfig < Chef::Provider::LWRPBase | ||
use_inline_resources if defined?(use_inline_resources) | ||
|
||
def whyrun_supported? | ||
true | ||
end | ||
|
||
action :create do | ||
directory new_resource.path do | ||
owner new_resource.run_user | ||
group new_resource.run_group | ||
mode '0644' | ||
end | ||
|
||
# TODO: (jbellone) Figure out a better way to generate this set of | ||
# options. Right now this is a bit messy. Especially if options | ||
# are added after the fact. | ||
invalid_options = [:path, :run_user, :run_group] | ||
configuration = new_resource.to_hash.reject { |k, v| invalid_options.include?(k) } | ||
file new_resource.filename do | ||
user new_resource.run_user | ||
group new_resource.run_group | ||
content JSON.pretty_generate(configuration, quirks_mode: true) | ||
mode '0600' | ||
action :create | ||
end | ||
end | ||
|
||
action :delete do | ||
file new_resource.filename do | ||
action :delete | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Provider::ConsulService < Chef::Provider::LWRPBase | ||
use_inline_resources if defined?(use_inline_resources) | ||
|
||
def whyrun_supported? | ||
true | ||
end | ||
|
||
action :create do | ||
end | ||
|
||
action :delete do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Provider::ConsulServiceSystemd < Chef::Provider::ConsulService | ||
action :start do | ||
runit_service 'consul' do | ||
supports status: true, restart: true, reload: true | ||
action :start | ||
end | ||
end | ||
|
||
action :stop do | ||
runit_service 'consul' do | ||
supports status: true, restart: true, reload: true | ||
action :stop | ||
end | ||
end | ||
|
||
action :restart do | ||
runit_service 'consul' do | ||
supports status: true, restart: true, reload: true | ||
action :restart | ||
end | ||
end | ||
|
||
action :reload do | ||
runit_service 'consul' do | ||
supports status: true, restart: true, reload: true | ||
action :reload | ||
reload_command %Q(#{node['runit']['sv_bin']} hup #{service_name}) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Provider::ConsulServiceSystemd < Chef::Provider::ConsulService | ||
action :start do | ||
service 'consul' do | ||
supports status: true, restart: true, reload: true | ||
provider Chef::Provider::Service::Init::Systemd | ||
action [:start, :enable] | ||
end | ||
end | ||
|
||
action :stop do | ||
service 'consul' do | ||
supports status: true, restart: true, reload: true | ||
provider Chef::Provider::Service::Init::Systemd | ||
action :stop | ||
end | ||
end | ||
|
||
action :restart do | ||
service 'consul' do | ||
supports status: true, restart: true, reload: true | ||
provider Chef::Provider::Service::Init::Systemd | ||
action :restart | ||
end | ||
end | ||
|
||
action :reload do | ||
service 'consul' do | ||
supports status: true, restart: true, reload: true | ||
provider Chef::Provider::Service::Init::Systemd | ||
action :reload | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Provider::ConsulServiceSysvinit < Chef::Provider::ConsulService | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Provider::ConsulServiceUpstart < Chef::Provider::ConsulService | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Resource::ConsulClient < Chef::Resource::LWRPBase | ||
self.resource_name = :consul_client | ||
actions :create, :delete | ||
default_action :create | ||
|
||
attribute :path, kind_of: String, name_attribute: true, required: true | ||
attribute :run_user, kind_of: String, required: true | ||
attribute :run_group, kind_of: String, required: true | ||
attribute :url, kind_of: String, required: true, default: nil | ||
attribute :version, kind_of: String, required: true, default: nil | ||
attribute :checksum, kind_of: String, default: nil | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Resource::ConsulConfig < Chef::Resource::LWRPBase | ||
self.resource_name = :consul_config | ||
actions :create, :delete | ||
default_action :create | ||
|
||
attribute :path, kind_of: String, required: true, name_attribute: true | ||
attribute :run_user, kind_of: String, required: true | ||
attribute :run_group, kind_of: String, required: true | ||
|
||
# @see: http://www.consul.io/docs/agent/options.html | ||
attribute :acl_datacenter, kind_of: String, default: nil | ||
attribute :acl_default_policy, kind_of: String, default: nil | ||
attribute :acl_down_policy, kind_of: String, default: nil | ||
attribute :acl_master_token, kind_of: String, default: nil | ||
attribute :acl_token, kind_of: String, default: nil | ||
attribute :acl_ttl, kind_of: String, default: nil | ||
attribute :addresses, kind_of: Hash, default: nil | ||
attribute :advertise_addr, kind_of: String, default: nil | ||
attribute :bind_addr, kind_of: String, default: nil | ||
attribute :bootstrap, kind_of: [TrueClass, FalseClass], default: false | ||
attribute :bootstrap_expect, kind_of: Number, default: 3 | ||
attribute :ca_file, kind_of: String, default: nil | ||
attribute :cert_file, kind_of: String, default: nil | ||
attribute :check_update_interval, kind_of: String, default: nil | ||
attribute :client_addr, kind_of: String, default: nil | ||
attribute :data_dir, kind_of: String, default: nil | ||
attribute :datacenter, kind_of: String, default: nil | ||
attribute :disable_anonymous_signature, kind_of: [TrueClass, FalseClass], default: false | ||
attribute :disable_remote_exec, kind_of: [TrueClass, FalseClass], default: false | ||
attribute :disable_update_check, kind_of: [TrueClass, FalseClass], default: false | ||
attribute :dns_config, kind_of: Hash, default: nil | ||
attribute :domain, kind_of: String, default: nil | ||
attribute :enable_debug, kind_of: [TrueClass, FalseClass], default: false | ||
attribute :enable_syslog, kind_of: [TrueClass, FalseClass], default: false | ||
attribute :encrypt, kind_of: String, default: nil | ||
attribute :key_file, kind_of: String, default: nil | ||
attribute :leave_on_terminate, kind_of: [TrueClass, FalseClass], default: false | ||
attribute :log_level, kind_of: String, default: 'INFO' | ||
attribute :node_name, kind_of: String, default: nil | ||
attribute :ports, kind_of: Hash, default: nil | ||
attribute :protocol, kind_of: String, default: nil | ||
attribute :recursor, kind_of: String, default: nil | ||
attribute :retry_interval, kind_of: Number, default: nil | ||
attribute :server, kind_of: [TrueClass, FalseClass], default: true | ||
attribute :server_name, kind_of: String, default: nil | ||
attribute :skip_leave_on_interrupt, kind_of: [TrueClass, FalseClass], default: false | ||
attribute :start_join, kind_of: Array, default: [] | ||
attribute :statsd_addr, kind_of: String, default: nil | ||
attribute :statsite_addr, kind_of: String, default: nil | ||
attribute :syslog_facility, kind_of: String, default: nil | ||
attribute :ui_dir, kind_of: String, default: nil | ||
attribute :verify_incoming, kind_of: [TrueClass, FalseClass], default: false | ||
attribute :verify_outgoing, kind_of: [TrueClass, FalseClass], default: false | ||
attribute :watches, kind_of: Hash, default: nil | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# | ||
# Cookbook Name:: consul | ||
# License:: Apache 2.0 | ||
# | ||
# Copyright 2014, 2015 Bloomberg Finance L.P. | ||
# | ||
|
||
class Chef::Resource::ConsulService < Chef::Resource::LWRPBase | ||
self.resource_name = :consul_service | ||
actions :start, :stop, :restart, :enable, :disable, :reload | ||
default_action :start | ||
|
||
attribute :service_name, type: String, name_attribute: true, required: true | ||
end |
Oops, something went wrong.