From fca65b8710668da4646e49cc91d7524f047ab116 Mon Sep 17 00:00:00 2001 From: Justice London Date: Fri, 12 Jul 2013 18:14:53 -0400 Subject: Release of 0.0.2 module which includes template base configuration for trocla CLI. --- templates/troclarc.yaml.erb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 templates/troclarc.yaml.erb (limited to 'templates/troclarc.yaml.erb') diff --git a/templates/troclarc.yaml.erb b/templates/troclarc.yaml.erb new file mode 100644 index 0000000..3f473fe --- /dev/null +++ b/templates/troclarc.yaml.erb @@ -0,0 +1,9 @@ +--- +options: + random: true + length: <%= @keysize %> +adapter: :<%= @adapter %> +adapter_options: +<% @adapter_options.each do |key,value| -%> + :<%= key -%>: '<%= value -%>' +<% end -%> -- cgit v1.2.3 From 9da000c6511e85e030e431b7d951d325c2c98681 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 2 Oct 2013 10:28:01 +0200 Subject: Improve the overall experience of the module. - Extending the README - Add a trocla::yaml class for a simple quickstart. - Fixes issues: #4 & #5 --- templates/troclarc.yaml.erb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'templates/troclarc.yaml.erb') diff --git a/templates/troclarc.yaml.erb b/templates/troclarc.yaml.erb index 3f473fe..d574cd9 100644 --- a/templates/troclarc.yaml.erb +++ b/templates/troclarc.yaml.erb @@ -1,9 +1,11 @@ --- options: - random: true - length: <%= @keysize %> + random: <%= @random_passwords %> + length: <%= @password_length %> adapter: :<%= @adapter %> +<% unless @adapter_options.empty? %> adapter_options: <% @adapter_options.each do |key,value| -%> - :<%= key -%>: '<%= value -%>' + :<%= key %>: '<%= value %>' +<% end -%> <% end -%> -- cgit v1.2.3 From 91d91c253b792b5a176159e083eb1a3f301a7e86 Mon Sep 17 00:00:00 2001 From: Timo Goebel Date: Sun, 1 Mar 2015 19:13:57 +0100 Subject: add support for encryption and ssl_options --- templates/troclarc.yaml.erb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'templates/troclarc.yaml.erb') diff --git a/templates/troclarc.yaml.erb b/templates/troclarc.yaml.erb index d574cd9..7d4fa27 100644 --- a/templates/troclarc.yaml.erb +++ b/templates/troclarc.yaml.erb @@ -9,3 +9,12 @@ adapter_options: :<%= key %>: '<%= value %>' <% end -%> <% end -%> +<% if @encryption %> +encryption: :<%= @encryption %> +<% end -%> +<% unless @ssl_options.empty? %> +ssl_options: +<% @ssl_options.each do |key,value| -%> + :<%= key %>: '<%= value %>' +<% end -%> +<% end -%> -- cgit v1.2.3 From bf49729c0e4b9c399afdf7a89051e549ab5c95bd Mon Sep 17 00:00:00 2001 From: Timo Goebel Date: Thu, 2 Apr 2015 15:04:54 +0200 Subject: sort encryption options --- templates/troclarc.yaml.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'templates/troclarc.yaml.erb') diff --git a/templates/troclarc.yaml.erb b/templates/troclarc.yaml.erb index d574cd9..9f269bf 100644 --- a/templates/troclarc.yaml.erb +++ b/templates/troclarc.yaml.erb @@ -5,7 +5,7 @@ options: adapter: :<%= @adapter %> <% unless @adapter_options.empty? %> adapter_options: -<% @adapter_options.each do |key,value| -%> - :<%= key %>: '<%= value %>' +<% @adapter_options.keys.sort.each do |key| -%> + :<%= key %>: '<%= @adapter_options[key] %>' <% end -%> <% end -%> -- cgit v1.2.3 From 0341407287268d0a14ae410fa085d8036251164a Mon Sep 17 00:00:00 2001 From: Timo Goebel Date: Thu, 9 Apr 2015 10:52:09 +0200 Subject: sort ssl_options --- templates/troclarc.yaml.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'templates/troclarc.yaml.erb') diff --git a/templates/troclarc.yaml.erb b/templates/troclarc.yaml.erb index ddadc3a..cd4da3d 100644 --- a/templates/troclarc.yaml.erb +++ b/templates/troclarc.yaml.erb @@ -14,7 +14,7 @@ encryption: :<%= @encryption %> <% end -%> <% unless @ssl_options.empty? %> ssl_options: -<% @ssl_options.each do |key,value| -%> - :<%= key %>: '<%= value %>' +<% @ssl_options.keys.sort.each do |key| -%> + :<%= key %>: '<%= @ssl_options[key] %>' <% end -%> <% end -%> -- cgit v1.2.3 From 8ca75f6d074b83ee48d9ce713cdb3e28e57d2cf8 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 28 Jan 2016 00:55:26 +0100 Subject: update module to make it work with all the new features of trocla 0.2.2 --- templates/troclarc.yaml.erb | 62 +++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 19 deletions(-) (limited to 'templates/troclarc.yaml.erb') diff --git a/templates/troclarc.yaml.erb b/templates/troclarc.yaml.erb index cd4da3d..5584fd8 100644 --- a/templates/troclarc.yaml.erb +++ b/templates/troclarc.yaml.erb @@ -1,20 +1,44 @@ ---- -options: - random: <%= @random_passwords %> - length: <%= @password_length %> -adapter: :<%= @adapter %> -<% unless @adapter_options.empty? %> -adapter_options: -<% @adapter_options.keys.sort.each do |key| -%> - :<%= key %>: '<%= @adapter_options[key] %>' -<% end -%> -<% end -%> -<% if @encryption %> -encryption: :<%= @encryption %> -<% end -%> -<% unless @ssl_options.empty? %> -ssl_options: -<% @ssl_options.keys.sort.each do |key| -%> - :<%= key %>: '<%= @ssl_options[key] %>' -<% end -%> +<% + # stupid but effective sorting of yaml + # forgive me for that, but puppet monkeypatches yaml heavily and breaks it constantly + # for our use case it should be sufficient, otherwise we need to + # extent it to address the new problems + def sort_pseudo_yaml(obj, indent='') + arr = obj.sort {|a,b| (a[0].is_a?(Symbol) ? a[0].to_s : a[0]) <=> (b[0].is_a?(Symbol) ? b[0].to_s : b[0]) } + out = [] + arr.each do |e| + if e[1].is_a?(Hash) + out << "#{indent}#{e[0]}:" + out << sort_pseudo_yaml(e[1],indent+' ') + elsif e[1].is_a?(Array) + out << (["#{indent}#{e[0]}:"]+e[1].collect{|e| "- #{e}" }).join("\n#{indent}") + else + out << "#{indent}#{e[0].is_a?(Symbol) ? ":#{e[0].to_s}" : e[0]}: #{e[1].is_a?(Symbol) ? ":#{e[1].to_s}" : e[1]}" + end + end + out.join("\n") + end + def sym_keys(h) + h.keys.inject({}) do |r,k| + r[k.to_sym] = h[k] + r + end + end + # transform special options so they are understood by the other libraries + so = @store_options.dup + so['adapter'] = so['adapter'].to_sym if so['adapter'] + so['adapter_options'] = sym_keys(so['adapter_options']) if so['adapter_options'] + eo = @encryption_options ? sym_keys(@encryption_options) : {} + options_hash = { + 'store' => @store.nil? ? @store : @store.to_sym, + 'store_options' => so, + 'encryption' => @encryption.nil? ? @encryption : @encryption.to_sym, + 'encryption_options' => eo, + 'options' => @options, + 'profiles' => @merged_profiles, + }.delete_if{|k,v| v.nil? || (v.is_a?(Symbol) ? v.to_s : v).empty? } + output = sort_pseudo_yaml(options_hash) +-%>--- +<% unless output.empty? -%> +<%= output %> <% end -%> -- cgit v1.2.3