tiller 0.7.3 → 0.7.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/bin/tiller +4 -4
- data/lib/tiller/api.rb +1 -1
- data/lib/tiller/api/handlers/templates.rb +5 -5
- data/lib/tiller/data/defaults.rb +17 -3
- data/lib/tiller/data/file.rb +1 -1
- data/lib/tiller/data/xml_file.rb +1 -1
- data/lib/tiller/logger.rb +1 -1
- data/lib/tiller/util.rb +1 -1
- metadata +2 -26
- data/examples/defaults.d/common.yaml +0 -9
- data/examples/defaults.d/defaults.d/app.conf.yaml +0 -2
- data/examples/defaults.d/defaults.d/global.yaml +0 -2
- data/examples/defaults.d/defaults.yaml +0 -5
- data/examples/defaults.d/environments/production.yaml +0 -4
- data/examples/defaults.d/environments/staging.yaml +0 -5
- data/examples/defaults.d/templates/app.conf.erb +0 -9
- data/examples/defaults/common.yaml +0 -9
- data/examples/defaults/defaults.yaml +0 -5
- data/examples/defaults/environments/production.yaml +0 -4
- data/examples/defaults/environments/staging.yaml +0 -5
- data/examples/defaults/templates/app.conf.erb +0 -9
- data/examples/json/common.yaml +0 -6
- data/examples/json/environments/array.yaml +0 -4
- data/examples/json/environments/simple_keys.yaml +0 -4
- data/examples/json/templates/array.erb +0 -4
- data/examples/json/templates/simple_keys.erb +0 -4
- data/examples/plugins/etc/tiller/common.yaml +0 -37
- data/examples/plugins/etc/tiller/environments/production.yaml +0 -27
- data/examples/plugins/etc/tiller/environments/staging.yaml +0 -24
- data/examples/plugins/etc/tiller/templates/sensu_client.erb +0 -8
- data/examples/plugins/lib/tiller/data/dummy.rb +0 -25
- data/examples/plugins/lib/tiller/data/network.rb +0 -15
- data/examples/plugins/lib/tiller/template/dummy.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81f462b7034a8c815eb6e561948cba295dbf3761
|
4
|
+
data.tar.gz: 5254ffc7b3ea0e2811fc44be2e54f8ff80e48e65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ce3e1d4b293f1b74ddabb9e8681b62a17016e27962713a8821393572354cd8aa23bc8b81ec07144e289ccfe20b7960b593658bb624f2dfeb8e929b59c530f90
|
7
|
+
data.tar.gz: 8c37b29ade6d27a3fe9cad11b36d2e80ecd954f14a2b12adc3897146e727cd62ba6b25e3d38a0e28feef2c83d579656d35d6e180df475cea120a9beaf6d33508
|
data/bin/tiller
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
#
|
9
9
|
# Mark Dastmalchi-Round <github@markround.com>
|
10
10
|
|
11
|
-
VERSION = '0.7.
|
11
|
+
VERSION = '0.7.4'
|
12
12
|
|
13
13
|
require 'erb'
|
14
14
|
require 'ostruct'
|
@@ -45,7 +45,7 @@ module Tiller
|
|
45
45
|
begin
|
46
46
|
common_file = File.join(config[:tiller_base], 'common.yaml')
|
47
47
|
config.merge!(YAML.load(open(common_file)))
|
48
|
-
rescue
|
48
|
+
rescue StandardError => e
|
49
49
|
abort "Error : Could not open common configuration file!\n#{e}"
|
50
50
|
end
|
51
51
|
|
@@ -152,7 +152,7 @@ module Tiller
|
|
152
152
|
# config is redundant in target_values, remove it for the final status hash.
|
153
153
|
all_templates[template] = {
|
154
154
|
'merged_values' => tiller,
|
155
|
-
'target_values' => target_values.reject{|k,
|
155
|
+
'target_values' => target_values.reject{|k,_v| k=='config'}
|
156
156
|
}
|
157
157
|
|
158
158
|
# Set permissions if we are running as root
|
@@ -189,7 +189,7 @@ module Tiller
|
|
189
189
|
|
190
190
|
if config[:no_exec] == false && config.key?('exec')
|
191
191
|
# All templates created, so let's start the replacement process
|
192
|
-
puts "Executing #{config['exec']
|
192
|
+
puts "Executing #{config['exec']}..."
|
193
193
|
|
194
194
|
# Spawn and wait so API can continue to run
|
195
195
|
child_pid = launch(config['exec'], :verbose => config[:verbose])
|
data/lib/tiller/api.rb
CHANGED
@@ -4,11 +4,11 @@ require 'tiller/api/handlers/404'
|
|
4
4
|
def handle_templates(api_version, tiller_api_hash)
|
5
5
|
case api_version
|
6
6
|
when 'v1'
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
{
|
8
|
+
:content => dump_json(tiller_api_hash['templates'].keys),
|
9
|
+
:status => '200 OK'
|
10
|
+
}
|
11
11
|
else
|
12
12
|
handle_404
|
13
|
-
end
|
14
13
|
end
|
14
|
+
end
|
data/lib/tiller/data/defaults.rb
CHANGED
@@ -4,7 +4,7 @@ require 'yaml'
|
|
4
4
|
# Thanks, StackOverflow ;)
|
5
5
|
class ::Hash
|
6
6
|
def deep_merge!(second)
|
7
|
-
merger = proc { |
|
7
|
+
merger = proc { |_key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
|
8
8
|
self.merge!(second, &merger)
|
9
9
|
end
|
10
10
|
end
|
@@ -52,7 +52,15 @@ class DefaultsDataSource < Tiller::DataSource
|
|
52
52
|
|
53
53
|
if @defaults_hash.key?(template_name)
|
54
54
|
values = @defaults_hash[template_name]
|
55
|
-
values.
|
55
|
+
if values.is_a? Hash
|
56
|
+
values.key?('config') ? values['config'] : values
|
57
|
+
else
|
58
|
+
# Previous versions of Tiller didn't throw an error when we had an empty
|
59
|
+
# template config definition in a defaults file. Tiller 0.7.3 "broke" this, so while it's arguably the
|
60
|
+
# correct thing to bail out, in the interests of backwards-compatibility, we now instead log a warning and continue.
|
61
|
+
@log.warn("Warning, empty config for #{template_name}")
|
62
|
+
Hash.new
|
63
|
+
end
|
56
64
|
else
|
57
65
|
Hash.new
|
58
66
|
end
|
@@ -61,7 +69,13 @@ class DefaultsDataSource < Tiller::DataSource
|
|
61
69
|
def target_values(template_name)
|
62
70
|
if @defaults_hash.key?(template_name)
|
63
71
|
values = @defaults_hash[template_name]
|
64
|
-
values.
|
72
|
+
if values.is_a? Hash
|
73
|
+
values.key?('target') ? values : Hash.new
|
74
|
+
else
|
75
|
+
# See comments for values function.
|
76
|
+
@log.warn("Warning, empty config for #{template_name}")
|
77
|
+
Hash.new
|
78
|
+
end
|
65
79
|
else
|
66
80
|
Hash.new
|
67
81
|
end
|
data/lib/tiller/data/file.rb
CHANGED
@@ -24,7 +24,7 @@ class FileDataSource < Tiller::DataSource
|
|
24
24
|
"#{@config[:environment]}.yaml")
|
25
25
|
@config_hash = YAML.load(open(env_file))
|
26
26
|
rescue
|
27
|
-
abort
|
27
|
+
abort("Error : Could not load environment file #{env_file}")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/tiller/data/xml_file.rb
CHANGED
@@ -20,7 +20,7 @@ class XmlFileDataSource < Tiller::DataSource
|
|
20
20
|
@log.info('Opening XML file : ' + path)
|
21
21
|
begin
|
22
22
|
xml = Crack::XML.parse(File.open(path))
|
23
|
-
rescue
|
23
|
+
rescue StandardError => e
|
24
24
|
abort "Error : Could not parse XML file #{path}\n#{e}"
|
25
25
|
end
|
26
26
|
struct = {}
|
data/lib/tiller/logger.rb
CHANGED
@@ -10,7 +10,7 @@ module Tiller
|
|
10
10
|
self.level = Logger::INFO if config[:verbose]
|
11
11
|
self.level = Logger::DEBUG if config[:debug]
|
12
12
|
|
13
|
-
self.formatter = proc do |
|
13
|
+
self.formatter = proc do |_severity, _datetime, _progname, msg|
|
14
14
|
"#{msg}\n"
|
15
15
|
end
|
16
16
|
|
data/lib/tiller/util.rb
CHANGED
@@ -23,7 +23,7 @@ def signal(sig, pid, options={})
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# Launch the replacement process.
|
26
|
-
def launch(cmd,
|
26
|
+
def launch(cmd, _options={})
|
27
27
|
# If an array, then we use a different form of spawn() which
|
28
28
|
# avoids a subshell. See https://github.com/markround/tiller/issues/8
|
29
29
|
if cmd.is_a?(Array)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Dastmalchi-Round
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A tool to create configuration files from a variety of sources, particularly
|
14
14
|
useful for Docker containers. See https://github.com/markround/tiller for examples
|
@@ -20,30 +20,6 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- bin/tiller
|
23
|
-
- examples/defaults.d/common.yaml
|
24
|
-
- examples/defaults.d/defaults.d/app.conf.yaml
|
25
|
-
- examples/defaults.d/defaults.d/global.yaml
|
26
|
-
- examples/defaults.d/defaults.yaml
|
27
|
-
- examples/defaults.d/environments/production.yaml
|
28
|
-
- examples/defaults.d/environments/staging.yaml
|
29
|
-
- examples/defaults.d/templates/app.conf.erb
|
30
|
-
- examples/defaults/common.yaml
|
31
|
-
- examples/defaults/defaults.yaml
|
32
|
-
- examples/defaults/environments/production.yaml
|
33
|
-
- examples/defaults/environments/staging.yaml
|
34
|
-
- examples/defaults/templates/app.conf.erb
|
35
|
-
- examples/json/common.yaml
|
36
|
-
- examples/json/environments/array.yaml
|
37
|
-
- examples/json/environments/simple_keys.yaml
|
38
|
-
- examples/json/templates/array.erb
|
39
|
-
- examples/json/templates/simple_keys.erb
|
40
|
-
- examples/plugins/etc/tiller/common.yaml
|
41
|
-
- examples/plugins/etc/tiller/environments/production.yaml
|
42
|
-
- examples/plugins/etc/tiller/environments/staging.yaml
|
43
|
-
- examples/plugins/etc/tiller/templates/sensu_client.erb
|
44
|
-
- examples/plugins/lib/tiller/data/dummy.rb
|
45
|
-
- examples/plugins/lib/tiller/data/network.rb
|
46
|
-
- examples/plugins/lib/tiller/template/dummy.rb
|
47
23
|
- lib/tiller/api.rb
|
48
24
|
- lib/tiller/api/handlers/404.rb
|
49
25
|
- lib/tiller/api/handlers/config.rb
|
data/examples/json/common.yaml
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# Example configuration file, demonstrating how to use Tiller.
|
2
|
-
#
|
3
|
-
# These examples create two templates with different values depending on if you set the environment to
|
4
|
-
# "production" or "staging".
|
5
|
-
#
|
6
|
-
# This would be called with the following environment variables set (e.g. from a bash prompt) :
|
7
|
-
#
|
8
|
-
# tiller_base=$PWD/examples/etc/tiller tiller_lib=$PWD/examples/lib tiller
|
9
|
-
#
|
10
|
-
# (Tiller uses the "production" environment if none is set). Or, for staging:
|
11
|
-
#
|
12
|
-
# environment=staging tiller_base=$PWD/examples/etc/tiller tiller_lib=$PWD/examples/lib tiller
|
13
|
-
#
|
14
|
-
# See the documentation for more details on how to use this in a Dockerfile.
|
15
|
-
|
16
|
-
# exec: The executable to handover to after execution. In a Dockerfile, this would probably be /usr/bin/supervisord
|
17
|
-
# Or some other daemon. For testing, /usr/bin/date (or similar) is a useful one-shot command that just exits,
|
18
|
-
# so you can inspect your templates.
|
19
|
-
exec: date
|
20
|
-
|
21
|
-
# data_sources: Sources of data. Here, we're pulling in the provided FileDataSource and EnvironmentDataSource (ships with
|
22
|
-
# this gem), and also the NetworkDataSource under examples/lib/tiller. This is found because we set tiller_lib when we
|
23
|
-
# called the tiller executable. We're not pulling in the example DummyDataSource, because it also provides target_values,
|
24
|
-
# so would overwrite the target_values from FileDataSource - you should only have one DataSource providing this information,
|
25
|
-
# otherwise your templates may end up in strange places you didn't expect!
|
26
|
-
data_sources:
|
27
|
-
- file
|
28
|
-
- environment
|
29
|
-
- network
|
30
|
-
|
31
|
-
|
32
|
-
# template_sources: Sources of templates, in priority order (first takes precendence). Again using the provided
|
33
|
-
# FileTemplateSource (uses templates under <tiller_base>/templates), and also because we set tiller_lib, we can use
|
34
|
-
# DummyTemplateSource which creates a single "dummy.erb" template.
|
35
|
-
template_sources:
|
36
|
-
- file
|
37
|
-
- dummy
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# Here is an example configuration file for your production environment.
|
2
|
-
|
3
|
-
# We override a setting from common.yaml for this environment.
|
4
|
-
common:
|
5
|
-
api_enable: true
|
6
|
-
exec: env
|
7
|
-
|
8
|
-
# First, we define the values for an example sensu_client template :
|
9
|
-
sensu_client.erb:
|
10
|
-
target: /etc/sensu/conf.d/client.json
|
11
|
-
config:
|
12
|
-
sensu_host: 'sensu.example.com'
|
13
|
-
sensu_subscriptions:
|
14
|
-
- common
|
15
|
-
- physical
|
16
|
-
- mongo
|
17
|
-
|
18
|
-
# This is a dummy template provided by the DummyTemplateSource. You'll notice that because we're not pulling in
|
19
|
-
# DummyDataSource, the dummy_global variable is not set, but the template is still built without an error (the
|
20
|
-
# value is just left blank).
|
21
|
-
dummy.erb:
|
22
|
-
target: /tmp/files/dummy.txt
|
23
|
-
owner: root
|
24
|
-
group: wheel
|
25
|
-
perms: 0644
|
26
|
-
config:
|
27
|
-
dummy: 'Text from a filesource - production environment'
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# Here is an example configuration file for your staging environment.
|
2
|
-
|
3
|
-
# First, we define the values for an example sensu_client template. In this example, we changed to including a "virtual"
|
4
|
-
# subscription instead of "physical", which was set in the production environment.
|
5
|
-
sensu_client.erb:
|
6
|
-
target: /etc/sensu/conf.d/client.json
|
7
|
-
config:
|
8
|
-
sensu_host: 'sensu.example.com'
|
9
|
-
sensu_subscriptions:
|
10
|
-
- common
|
11
|
-
- virtual
|
12
|
-
- mongo
|
13
|
-
|
14
|
-
# This is a dummy template provided by the DummyTemplateSource. You'll notice that because we're not pulling in
|
15
|
-
# DummyDataSource, the dummy_global variable is not set, but the template is still built without an error (the
|
16
|
-
# value is just left blank). Here we also write the file to a different location that the one in the production
|
17
|
-
# environment.
|
18
|
-
dummy.erb:
|
19
|
-
target: /tmp/files/dummy-staging.txt
|
20
|
-
owner: root
|
21
|
-
group: wheel
|
22
|
-
perms: 0644
|
23
|
-
config:
|
24
|
-
dummy: 'Text from a filesource - staging environment'
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# This is a "dummy" datasource for Tiller. All it does is provide a single
|
2
|
-
# global and local value, and shows how you can provide a hash of target values
|
3
|
-
# to configure where templates are written.
|
4
|
-
class DummyDataSource < Tiller::DataSource
|
5
|
-
def global_values
|
6
|
-
{ 'dummy_global' => 'dummy global replacement text' }
|
7
|
-
end
|
8
|
-
|
9
|
-
def values(_template_name)
|
10
|
-
{ 'dummy' => 'dummy replacement text' }
|
11
|
-
end
|
12
|
-
|
13
|
-
# Dummy values, useful for testing. Will just result in the template being
|
14
|
-
# built and written to /tmp/dummy. Remember that perms must be in octal
|
15
|
-
# (no quotes). Note that as you have the environment name in the @config hash,
|
16
|
-
# you can always return different values for different environments.
|
17
|
-
def target_values(template_name)
|
18
|
-
{
|
19
|
-
'target' => "/tmp/dummy/#{template_name}",
|
20
|
-
'user' => 'root',
|
21
|
-
'group' => 'root',
|
22
|
-
'perms' => 0644
|
23
|
-
}
|
24
|
-
end
|
25
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'socket'
|
2
|
-
# This is a quick example of a global datasource for Tiller.
|
3
|
-
# It shows how you might provide some basic network-related information to your
|
4
|
-
# templates. It's a super quick and hacky, but serves as a useful example.
|
5
|
-
# You can then do things like <%= fqdn %> or <%= ipv4_addresses[0][3] %> in
|
6
|
-
# your templates.
|
7
|
-
class NetworkDataSource < Tiller::DataSource
|
8
|
-
def global_values
|
9
|
-
# Note, these rely on DNS being available and configured correctly!
|
10
|
-
{
|
11
|
-
'fqdn' => Socket.gethostbyname(Socket.gethostname).first,
|
12
|
-
'ipv4_addresses' => Socket.getaddrinfo(Socket.gethostbyname(Socket.gethostname).first, nil, :INET)
|
13
|
-
}
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# This is another quick example of how to create a template source.
|
2
|
-
class DummyTemplateSource < Tiller::TemplateSource
|
3
|
-
# Just provide a single dummy template
|
4
|
-
def templates
|
5
|
-
['dummy.erb']
|
6
|
-
end
|
7
|
-
|
8
|
-
# And return some sample ERB content.
|
9
|
-
# Note that as you have the environment name in the @config hash, you can
|
10
|
-
# always return different templates for different environments.
|
11
|
-
def template(_template_name)
|
12
|
-
"This is a dummy template! <%= dummy %> \n "\
|
13
|
-
'Here is a global value <%= dummy_global %>'
|
14
|
-
end
|
15
|
-
end
|