kondate 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +5 -6
- data/lib/ext/itamae/attributes.rb +9 -0
- data/lib/ext/serverspec/attributes.rb +3 -0
- data/lib/kondate/cli.rb +5 -3
- data/lib/kondate/host_plugin/file.rb +1 -1
- data/lib/kondate/property_builder.rb +7 -8
- data/lib/kondate/templates/bootstrap.rb +0 -1
- data/lib/kondate/templates/hosts.yml +1 -0
- data/lib/kondate/templates/properties/environments/development.yml +2 -0
- data/lib/kondate/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9cce6830f15dbb3ee4856a3d0c789b23ad2a615
|
4
|
+
data.tar.gz: b891c2c1d573bd93672453ad93b1a94a01770370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c342ae98969f5f2ae78579d9bc52b1b8d89ed79d68f8ebbdb2f98b9ae61c4cd2bfb37fc13bcaa64f8f4c6ddf560eef88ba921b0c170205224f757eac5dc3dd08
|
7
|
+
data.tar.gz: 6b1e8f7b907218e6c9aaded19ba8dbc66040c857b0aea9eae3b3844475d256df3fb96f49f335c56bda63aa554af5491093df5f7fc811ececbf5d1bf723fe3149
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -142,7 +142,7 @@ attributes:
|
|
142
142
|
nginx:
|
143
143
|
```
|
144
144
|
|
145
|
-
The attributes variables are accessible like `attrs['rbenv']['versions']
|
145
|
+
The attributes variables are accessible like `attrs['rbenv']['versions']`, which is equivalent and short version of `node['attributes']['rbenv']['versions']` in recipes.
|
146
146
|
|
147
147
|
You can also prepare host-specific property files such as:
|
148
148
|
|
@@ -159,12 +159,11 @@ In addition, you can also prepare environment property files such as:
|
|
159
159
|
properties/environments/development.yml
|
160
160
|
|
161
161
|
```
|
162
|
-
|
163
|
-
|
164
|
-
aws_region: ap-northeast-1
|
162
|
+
global_attributes:
|
163
|
+
aws_region: ap-northeast-1
|
165
164
|
```
|
166
165
|
|
167
|
-
|
166
|
+
where `global_attributes` is accessible like `global_attrs['aws_region']`, which is equivalent and short version of `node['global_attributes']['aws_region']` in recipes.
|
168
167
|
|
169
168
|
These files are merged on kondate execution in order of `environment` + `role` + `node` (`node` > `role` > `environment` in the strong order).
|
170
169
|
|
@@ -281,7 +280,7 @@ module Kondate
|
|
281
280
|
# @param [String] host hostname
|
282
281
|
# @return [String] environment name
|
283
282
|
def get_environment(host)
|
284
|
-
ENV['ENVIRONMENT']
|
283
|
+
ENV['ENVIRONMENT'] || 'development'
|
285
284
|
end
|
286
285
|
|
287
286
|
# @param [String] host hostname
|
@@ -5,6 +5,9 @@ module Itamae
|
|
5
5
|
def attrs
|
6
6
|
node[:attributes]
|
7
7
|
end
|
8
|
+
def global_attrs
|
9
|
+
node[:global_attributes]
|
10
|
+
end
|
8
11
|
end
|
9
12
|
end
|
10
13
|
end
|
@@ -17,6 +20,9 @@ module Itamae
|
|
17
20
|
def attrs
|
18
21
|
node[:attributes]
|
19
22
|
end
|
23
|
+
def global_attrs
|
24
|
+
node[:global_attributes]
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -30,6 +36,9 @@ module Itamae
|
|
30
36
|
def attrs
|
31
37
|
node[:attributes]
|
32
38
|
end
|
39
|
+
def global_attrs
|
40
|
+
node[:global_attributes]
|
41
|
+
end
|
33
42
|
end
|
34
43
|
end
|
35
44
|
end
|
data/lib/kondate/cli.rb
CHANGED
@@ -95,7 +95,6 @@ module Kondate
|
|
95
95
|
|
96
96
|
ENV['TARGET_NODE_FILE'] = property_file
|
97
97
|
recipes = YAML.load_file(property_file)['attributes'].keys.map {|recipe|
|
98
|
-
next if recipe == 'global'
|
99
98
|
File.join(Config.middleware_recipes_serverspec_dir, recipe)
|
100
99
|
}.compact
|
101
100
|
recipes << File.join(Config.roles_recipes_serverspec_dir, role)
|
@@ -110,8 +109,11 @@ module Kondate
|
|
110
109
|
|
111
110
|
def build_property_files(host)
|
112
111
|
builder = PropertyBuilder.new(host)
|
113
|
-
roles =
|
114
|
-
|
112
|
+
roles = builder.filter_roles(@options[:role])
|
113
|
+
if roles.nil? or roles.empty?
|
114
|
+
$stderr.puts 'No role'
|
115
|
+
exit(1)
|
116
|
+
end
|
115
117
|
$stdout.puts "roles: [#{roles.join(', ')}]"
|
116
118
|
|
117
119
|
property_files = {}
|
@@ -12,9 +12,9 @@ module Kondate
|
|
12
12
|
def environment
|
13
13
|
@environment ||=
|
14
14
|
begin
|
15
|
-
|
15
|
+
Config.host_plugin.get_environment(@host) || ''
|
16
16
|
rescue => e
|
17
|
-
$stderr.puts "cannot get environment
|
17
|
+
$stderr.puts "cannot get environment for host:#{@host}, #{e.class} #{e.message}"
|
18
18
|
''
|
19
19
|
end
|
20
20
|
end
|
@@ -22,15 +22,16 @@ module Kondate
|
|
22
22
|
def roles
|
23
23
|
@roles ||=
|
24
24
|
begin
|
25
|
-
|
25
|
+
Config.host_plugin.get_roles(@host) || []
|
26
26
|
rescue => e
|
27
|
-
$stderr.puts "cannot get roles
|
27
|
+
$stderr.puts "cannot get roles for host:#{@host}, #{e.class} #{e.message}"
|
28
28
|
[]
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def filter_roles(filters)
|
33
|
-
|
33
|
+
return self.roles if filters.nil? or filters.empty?
|
34
|
+
filters = Array(filters).map {|filter| filter.gsub(':', '-') }
|
34
35
|
if roles.empty? # maybe, development (vagrant) env
|
35
36
|
@roles = filters # append specified roles
|
36
37
|
@roles.each do |role|
|
@@ -46,7 +47,7 @@ module Kondate
|
|
46
47
|
end
|
47
48
|
unless filters.empty?
|
48
49
|
# filter out for production env
|
49
|
-
@roles = roles & filters
|
50
|
+
@roles = self.roles & filters
|
50
51
|
end
|
51
52
|
end
|
52
53
|
@roles
|
@@ -98,7 +99,6 @@ module Kondate
|
|
98
99
|
'environment' => environment,
|
99
100
|
'role' => role,
|
100
101
|
'roles' => roles,
|
101
|
-
'attributes' => {},
|
102
102
|
}).
|
103
103
|
deep_merge!(environment_property).
|
104
104
|
deep_merge!(secret_environment_property).
|
@@ -109,7 +109,6 @@ module Kondate
|
|
109
109
|
|
110
110
|
# filter out the recipe
|
111
111
|
if filter_recipes and !filter_recipes.empty?
|
112
|
-
filter_recipes << 'global'
|
113
112
|
property['attributes'].keys.each do |key|
|
114
113
|
property['attributes'].delete(key) unless filter_recipes.include?(key)
|
115
114
|
end
|
@@ -3,7 +3,6 @@ require 'kondate'
|
|
3
3
|
|
4
4
|
recipes = node['attributes'].keys
|
5
5
|
recipes.each do |recipe|
|
6
|
-
next if recipe == 'global'
|
7
6
|
include_recipe(File.join(Kondate::Config.middleware_recipes_dir, recipe, "default.rb"))
|
8
7
|
end
|
9
8
|
if File.exist?(File.join(Kondate::Config.roles_recipes_dir, node[:role], "default.rb"))
|
data/lib/kondate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kondate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sonots
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: itamae
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/kondate/templates/bootstrap.rb
|
151
151
|
- lib/kondate/templates/hosts.yml
|
152
152
|
- lib/kondate/templates/properties/environments/.gitkeep
|
153
|
+
- lib/kondate/templates/properties/environments/development.yml
|
153
154
|
- lib/kondate/templates/properties/nodes/.gitkeep
|
154
155
|
- lib/kondate/templates/properties/roles/sample.yml
|
155
156
|
- lib/kondate/templates/recipes/middleware/base/default.rb
|