Alexandros Kosiaris has uploaded a new change for review. https://gerrit.wikimedia.org/r/202756
Change subject: Allow hiera role_backend to be debuggable via hiera CLI ...................................................................... Allow hiera role_backend to be debuggable via hiera CLI The role backend for hiera is not very debuggable via hiera CLI. The reason is that the _roles variable passed to hiera needs to be a valid ruby hash. To facilitate debugging, if roles is a String, as when used in hiera CLI, parse it as a YAML document and reassign the roles variable to it Document it as well Change-Id: I62294646320925a716d643a0595e67c799df5c41 --- M modules/wmflib/lib/hiera/backend/role_backend.rb 1 file changed, 9 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/56/202756/1 diff --git a/modules/wmflib/lib/hiera/backend/role_backend.rb b/modules/wmflib/lib/hiera/backend/role_backend.rb index c7f46ba..5bca57f 100644 --- a/modules/wmflib/lib/hiera/backend/role_backend.rb +++ b/modules/wmflib/lib/hiera/backend/role_backend.rb @@ -66,6 +66,12 @@ # in unexpected behaviour so I advice _against_ using multiple role # keywords in a single node, if both roles include conflicting # classes. +# === Debugging with hiera cli +# If you want to debug with hiera CLI, you need to pass the _roles argument to +# hiera but without the role:: prefix. The argument must be of valid YAML +# syntax (which means JSON is accepted too). For example: +# +# hiera -d "::_roles={'myrole1': true, 'myrole2': true}" require 'yaml' class Hiera module Backend @@ -119,6 +125,9 @@ resultset = nil return nil unless scope.include?topscope_var roles = scope[topscope_var] + if roles.instance_of?(String) + Hiera.debug('Roles is a string, YAML parsing it') + roles = YAML.load(roles) return nil if roles.nil? if Config.include?(:role_hierarchy) hierarchy = Config[:role_hierarchy] -- To view, visit https://gerrit.wikimedia.org/r/202756 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I62294646320925a716d643a0595e67c799df5c41 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Alexandros Kosiaris <akosia...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits