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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8f5e91857574eaabc22cc65ed6f34233fba10c5
4
- data.tar.gz: 07397787296ef63c605c0ab20f766ab748ee58ef
3
+ metadata.gz: f9cce6830f15dbb3ee4856a3d0c789b23ad2a615
4
+ data.tar.gz: b891c2c1d573bd93672453ad93b1a94a01770370
5
5
  SHA512:
6
- metadata.gz: fc9ad5b77a844d9927b38f1a01f27d54be156f7234754d8e131deac276ea29fd35e4fc544bc5354660e72c9f6f32f5983a8b9135ec949729aedd074266987984
7
- data.tar.gz: 276617ad590a6040a19d2ab69a74e2abdbdeac9891117e48286a17ab4d79e455192a55897d4d0644024d4f008e92a195fa2b68ff0d239c94322190eb9344fe37
6
+ metadata.gz: c342ae98969f5f2ae78579d9bc52b1b8d89ed79d68f8ebbdb2f98b9ae61c4cd2bfb37fc13bcaa64f8f4c6ddf560eef88ba921b0c170205224f757eac5dc3dd08
7
+ data.tar.gz: 6b1e8f7b907218e6c9aaded19ba8dbc66040c857b0aea9eae3b3844475d256df3fb96f49f335c56bda63aa554af5491093df5f7fc811ececbf5d1bf723fe3149
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.1.4 (2015-11-29)
2
+
3
+ Changes:
4
+
5
+ * Define global_attributes instead of using attributes['global']
6
+ * Let vagrant? to handle inside each host plugin
7
+
1
8
  # 0.1.3 (2015-11-26)
2
9
 
3
10
  Fixes:
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']` in recipes, which is equivalent and short version of `node['attributes']['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
- attributes:
163
- global:
164
- aws_region: ap-northeast-1
162
+ global_attributes:
163
+ aws_region: ap-northeast-1
165
164
  ```
166
165
 
167
- The `global` is a reserved name, the `global` is used to only store global attributes, and do not run `global` recipe.
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
@@ -4,6 +4,9 @@ module Specinfra
4
4
  def attrs
5
5
  property['attributes']
6
6
  end
7
+ def global_attrs
8
+ property['global_attributes']
9
+ end
7
10
  end
8
11
  end
9
12
  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 = @options[:role] ? builder.filter_roles(@options[:role]) : builder.roles
114
- $stderr.puts 'No role' and exit(1) if roles.empty?
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 = {}
@@ -17,7 +17,7 @@ module Kondate
17
17
  # @param [String] host hostname
18
18
  # @return [String] environment name
19
19
  def get_environment(host)
20
- ENV['ENVIRONMENT']
20
+ ENV['ENVIRONMENT'] || 'development'
21
21
  end
22
22
 
23
23
  # @param [String] host hostname
@@ -12,9 +12,9 @@ module Kondate
12
12
  def environment
13
13
  @environment ||=
14
14
  begin
15
- vagrant? ? '' : Config.host_plugin.get_environment(@host)
15
+ Config.host_plugin.get_environment(@host) || ''
16
16
  rescue => e
17
- $stderr.puts "cannot get environment from host:#{@host}, #{e.class} #{e.message}"
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
- vagrant? ? [] : Config.host_plugin.get_roles(@host)
25
+ Config.host_plugin.get_roles(@host) || []
26
26
  rescue => e
27
- $stderr.puts "cannot get roles from host:#{@host}, #{e.class} #{e.message}"
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
- filters = Array(filters).map {|role| role.gsub(':', '-') }
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"))
@@ -1 +1,2 @@
1
1
  localhost: [sample]
2
+ vagrant-centos: [sample]
@@ -0,0 +1,2 @@
1
+ global_attributes:
2
+ aws_region: ap-northeast-1
@@ -1,3 +1,3 @@
1
1
  module Kondate
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
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.3
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-26 00:00:00.000000000 Z
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