Skip to content

Commit

Permalink
added plugin lwrp
Browse files Browse the repository at this point in the history
  • Loading branch information
agoddard committed Apr 29, 2014
1 parent ef86230 commit 6624394
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
47 changes: 47 additions & 0 deletions providers/plugin.rb
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
13 changes: 13 additions & 0 deletions resources/plugin.rb
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

0 comments on commit 6624394

Please sign in to comment.