This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathredis_installation.rb
103 lines (88 loc) · 2.19 KB
/
redis_installation.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#
# Cookbook: blp-redis
# License: Apache 2.0
#
# Copyright 2015-2016, Bloomberg Finance L.P.
#
require 'poise'
module RedisCookbook
module Resource
# An `redis_installation` resource which manages the Redis
# installation on the node.
# @provides redis_installation
# @action create
# @action remove
# @since 2.0
class RedisInstallation < Chef::Resource
include Poise(container: true, inversion: true)
provides(:redis_installation)
actions(:create, :remove)
default_action(:create)
# @!attribute version
# The version of Redis to install.
# @return [String]
attribute(:version, kind_of: String, name_attribute: true)
# @return [String]
def redis_program
provider_for_action(:redis_program).redis_program
end
# @return [String]
def sentinel_program
provider_for_action(:sentinel_program).sentinel_program
end
# @return [String]
def cli_program
provider_for_action(:cli_program).cli_program
end
end
end
module Provider
# The `redis_installation` base provider.
# @abstract
# @since 3.0
class RedisInstallation < Chef::Provider
include Poise(inversion: :redis_installation)
# Set the default inversion options.
# @private
def self.default_inversion_options(_node, new_resource)
super.merge(version: new_resource.version)
end
def action_create
notifying_block do
install_redis
end
end
def action_remove
notifying_block do
uninstall_redis
end
end
# @abstract
# @return [String]
def redis_program
raise NotImplementedError
end
# @abstract
# @return [String]
def sentinel_program
raise NotImplementedError
end
# @abstract
# @return [String]
def cli_program
raise NotImplementedError
end
private
# @abstract
# @return [void]
def install_redis
raise NotImplementedError
end
# @abstract
# @return [void]
def uninstall_redis
raise NotImplementedError
end
end
end
end