-
-
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.
Merge pull request #155 from hirocaster/watch-services
Add LWRP services watch
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 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,18 @@ | ||
use_inline_resources | ||
|
||
action :create do | ||
file new_resource.path do | ||
user node['consul']['service_user'] | ||
group node['consul']['service_group'] | ||
mode 0600 | ||
content new_resource.to_json | ||
|
||
action :create | ||
end | ||
end | ||
|
||
action :delete do | ||
file new_resource.path do | ||
action :delete | ||
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,27 @@ | ||
require 'json' | ||
|
||
actions :create, :delete | ||
default_action :create | ||
|
||
attribute :name, name_attribute: true, required: true, kind_of: String | ||
attribute :handler, required: true, kind_of: String | ||
|
||
def path | ||
::File.join(node['consul']['config_dir'], "watch-services.json") | ||
end | ||
|
||
def to_json | ||
JSON.pretty_generate(to_hash) | ||
end | ||
|
||
def to_hash | ||
hash = { | ||
watches:[ | ||
{ | ||
type: 'services', | ||
handler: handler | ||
} | ||
] | ||
} | ||
hash | ||
end |