shortdudey123 / chef-salt

Chef Cookbook for Salt
https://supermarket.chef.io/cookbooks/salt
Apache License 2.0
6 stars 15 forks source link

fix for helper salt_config immutable mash #45

Closed vkhatri closed 7 years ago

vkhatri commented 7 years ago

/etc/salt/master:

    +---
    +external_auth:
    +  pam:
    +    saltapi: !ruby/array:Chef::Node::ImmutableArray
    +      internal:
    +      - "@wheel"
    +      - "@runner"
    +      ivars:
    +        :@__path__: []
    +        :@__root__:
    +        :@__node__:
    +        :@__precedence__:

Instead, use below code (been using it in numerous cookbooks).

$ git diff libraries/helpers.rb
diff --git a/libraries/helpers.rb b/libraries/helpers.rb
index 9412bca..2571e12 100644
--- a/libraries/helpers.rb
+++ b/libraries/helpers.rb
@@ -6,7 +6,7 @@ require 'mixlib/log'

 module SaltCookbookHelper
   def salt_config(config)
-    config.to_hash.compact.sorted_hash.to_yaml
+    JSON.parse(config.to_json).to_yaml.lines.to_a[1..-1].join
   end
 end

Will submit a PR.

shortdudey123 commented 7 years ago

The method takes in a hash so that change would not be needed. (Not sure why i have the extra .to_hash though)