summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-04-08 12:41:45 -0700
committerelijah <elijah@riseup.net>2016-04-08 12:41:45 -0700
commite4f786e229c101cb60626ce23e671c5258466724 (patch)
tree40dadd2472462c05e731c7685db819d40b18c026
parent8dfb90f0ea7364f43669fe2105c6a031066b468f (diff)
partials - add support for leap_cli's inheritable service partials (requires latest develop branch leap_cli)
-rw-r--r--lib/leap_cli/macros/core.rb9
-rw-r--r--lib/leap_cli/macros/hosts.rb2
-rw-r--r--lib/leap_cli/macros/nodes.rb4
-rw-r--r--platform.rb5
-rw-r--r--provider_base/services/monitor.json2
-rw-r--r--provider_base/services/mx.rb2
6 files changed, 15 insertions, 9 deletions
diff --git a/lib/leap_cli/macros/core.rb b/lib/leap_cli/macros/core.rb
index ebea3a6e..873da358 100644
--- a/lib/leap_cli/macros/core.rb
+++ b/lib/leap_cli/macros/core.rb
@@ -47,8 +47,13 @@ module LeapCli
# applies a JSON partial to this node
#
def apply_partial(partial_path)
- manager.partials(partial_path).each do |partial_data|
- self.deep_merge!(partial_data)
+ if env.partials[partial_path]
+ self.deep_merge!(env.partials[partial_path])
+ else
+ raise ArgumentError.new(
+ "No such partial `%s`. Available partials include:\n%s" %
+ [partial_path, env.partials.keys.join(", ")]
+ )
end
end
diff --git a/lib/leap_cli/macros/hosts.rb b/lib/leap_cli/macros/hosts.rb
index 541bbc13..963857ae 100644
--- a/lib/leap_cli/macros/hosts.rb
+++ b/lib/leap_cli/macros/hosts.rb
@@ -17,7 +17,7 @@ module LeapCli
node_list = node_list['environment' => '!local']
end
node_list.map {|name, n|
- [n.ip_address, (global.facts[name]||{})['ec2_public_ipv4']]
+ [n.ip_address, (manager.facts[name]||{})['ec2_public_ipv4']]
}.flatten.compact.uniq
end
diff --git a/lib/leap_cli/macros/nodes.rb b/lib/leap_cli/macros/nodes.rb
index 8b961cbc..0e23831d 100644
--- a/lib/leap_cli/macros/nodes.rb
+++ b/lib/leap_cli/macros/nodes.rb
@@ -11,14 +11,14 @@ module LeapCli
# the list of all the nodes
#
def nodes
- global.nodes
+ env.nodes
end
#
# simple alias for global.provider
#
def provider
- global.provider
+ env.provider
end
#
diff --git a/platform.rb b/platform.rb
index 323ba4ea..1e19a2a9 100644
--- a/platform.rb
+++ b/platform.rb
@@ -38,13 +38,14 @@ Leap::Platform.define do
# input config files
:common_config => 'common.json',
:provider_config => 'provider.json',
- :secrets_config => 'secrets.json',
- :node_config => 'nodes/#{arg}.json',
:service_config => 'services/#{arg}.json',
:tag_config => 'tags/#{arg}.json',
:template_config => 'templates/#{arg}.json',
+ :secrets_config => 'secrets.json',
+ :node_config => 'nodes/#{arg}.json',
# input config files, environmentally scoped
+ :common_env_config => 'commmon.#{arg}.json',
:provider_env_config => 'provider.#{arg}.json',
:service_env_config => 'services/#{arg[0]}.#{arg[1]}.json',
:tag_env_config => 'tags/#{arg[0]}.#{arg[1]}.json',
diff --git a/provider_base/services/monitor.json b/provider_base/services/monitor.json
index 28fb837c..9ddc0ec7 100644
--- a/provider_base/services/monitor.json
+++ b/provider_base/services/monitor.json
@@ -2,7 +2,7 @@
"nagios": {
"nagiosadmin_pw": "= secret :nagios_admin_password",
"domains_internal": "= nagios.hosts.values.map{|h|h['domain_internal_suffix']}.uniq",
- "environments": "= Hash[ nagios.hosts.values.map{|h|h['environment']}.uniq.map{|e| [e||'default',{'contact_emails'=>global.env(e).provider.contacts.default}]} ]",
+ "environments": "= Hash[ nagios.hosts.values.map{|h|h['environment']}.uniq.map{|e| [e||'default',{'contact_emails'=>manager.env(e).provider.contacts.default}]} ]",
"hosts": "= (self.environment == 'local' ? nodes_like_me : nodes[:environment => '!local']).pick_fields('environment', 'domain.internal', 'domain.internal_suffix', 'domain.full_suffix', 'ip_address', 'services', 'openvpn.gateway_address', 'ssh.port')"
},
"hosts": "= self.environment == 'local' ? hosts_file(nodes_like_me) : hosts_file(nodes[:environment => '!local'])",
diff --git a/provider_base/services/mx.rb b/provider_base/services/mx.rb
index 741ff313..03ee561f 100644
--- a/provider_base/services/mx.rb
+++ b/provider_base/services/mx.rb
@@ -1 +1 @@
-apply_partial('services/_api_tester.json')
+apply_partial('_api_tester')