This repository has been archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Andrei Skopenko
committed
Aug 23, 2017
1 parent
afd8b26
commit f24b049
Showing
5 changed files
with
128 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
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,69 @@ | ||
# frozen_string_literal: true | ||
class Chef | ||
class Resource | ||
# provides icinga2_apiuser | ||
class Icinga2Apiuser < Chef::Resource | ||
identity_attr :name | ||
|
||
def initialize(name, run_context = nil) | ||
super | ||
@resource_name = :icinga2_apiuser if respond_to?(:resource_name) | ||
@provides = :icinga2_apiuser | ||
@provider = Chef::Provider::Icinga2Instance | ||
@action = :create | ||
@allowed_actions = [:create, :delete, :nothing] | ||
@name = name | ||
end | ||
|
||
def cookbook(arg = nil) | ||
set_or_return( | ||
:cookbook, arg, | ||
:kind_of => String, | ||
:default => 'icinga2' | ||
) | ||
end | ||
|
||
def password(arg = nil) | ||
set_or_return( | ||
:password, arg, | ||
:kind_of => String, | ||
:required => true, | ||
:default => nil | ||
) | ||
end | ||
|
||
def permissions(arg = nil) | ||
set_or_return( | ||
:permissions, arg, | ||
:kind_of => String, | ||
:required => true, | ||
:default => nil | ||
) | ||
end | ||
|
||
def client_cn(arg = nil) | ||
set_or_return( | ||
:client_cn, arg, | ||
:kind_of => String, | ||
:default => nil | ||
) | ||
end | ||
|
||
def template_support(arg = nil) | ||
set_or_return( | ||
:template_support, arg, | ||
:kind_of => [FalseClass], | ||
:default => false | ||
) | ||
end | ||
|
||
def resource_properties(arg = nil) | ||
set_or_return( | ||
:resource_properties, arg, | ||
:kind_of => Array, | ||
:default => %w(password permissions client_cn) | ||
) | ||
end | ||
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
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,22 @@ | ||
/** | ||
* This file is managed by Chef. | ||
* Do NOT modify this file directly. | ||
*/ | ||
|
||
/** | ||
* ApiUser Object. | ||
*/ | ||
|
||
<% @objects.sort.map do |object, options|%> | ||
object ApiUser <%= object.inspect -%> { | ||
<% if options['password'] -%> | ||
password = "<%= options['password'] %>" | ||
<% end -%> | ||
<% if options['permissions'] -%> | ||
permissions = <%= options['permissions'] %> | ||
<% end -%> | ||
<% if options['client_cn'] -%> | ||
client_cn = "<%= options['client_cn'] %>" | ||
<% end -%> | ||
} | ||
<% end -%> |