forked from sensu/sensu-chef
-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
def load_current_resource | ||
definition_directory = ::File.join(node.sensu.directory, "plugins") | ||
@definition_path = ::File.join(definition_directory, filename) | ||
end | ||
|
||
def filename | ||
if new_resource.filename | ||
new_resource.filename | ||
elsif new_resource.name.include? "::" | ||
new_resource.name.split("::").last | ||
else | ||
::File.basename(URI.parse(new_resource.name).path) | ||
end | ||
end | ||
|
||
action :create do | ||
if new_resource.name.include? "::" | ||
cookbook, file = new_resource.name.split("::") | ||
path = @definition_path | ||
f = cookbook_file file do | ||
cookbook cookbook | ||
path path | ||
mode new_resource.mode if new_resource.mode | ||
owner new_resource.owner if new_resource.owner | ||
group new_resource.group if new_resource.group | ||
rights new_resource.rights if new_resource.rights | ||
end | ||
else | ||
f = remote_file @definition_path do | ||
source new_resource.name | ||
mode new_resource.mode if new_resource.mode | ||
owner new_resource.owner if new_resource.owner | ||
group new_resource.group if new_resource.group | ||
rights new_resource.rights if new_resource.rights | ||
end | ||
end | ||
|
||
new_resource.updated_by_last_action(f.updated_by_last_action?) | ||
end | ||
|
||
action :delete do | ||
f = file @definition_path do | ||
action :delete | ||
end | ||
|
||
new_resource.updated_by_last_action(f.updated_by_last_action?) | ||
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,13 @@ | ||
actions :create, :delete | ||
|
||
attribute :source, :kind_of => String, :name_attribute => true | ||
attribute :filename, :kind_of => String | ||
attribute :mode, :kind_of => String, :default => '0755' | ||
attribute :owner, :kind_of => String | ||
attribute :group, :kind_of => String, :default => 'sensu' | ||
attribute :rights, :kind_of => String | ||
|
||
def initialize(*args) | ||
super | ||
@action = :create | ||
end |