salt icon indicating copy to clipboard operation
salt copied to clipboard

Re-apply #28134 (pillar unicode conversion)

Open basepi opened this issue 11 years ago • 3 comments

Need to figure out a way to properly handle unicode in pillar without causing jinja to put everything into templates with a leading u which messed YAML up.

Basically, re-apply #28134 with a fix for #28321 as well.

basepi avatar Nov 04 '15 18:11 basepi

Hi @basepi. I asked @bernieke if I can contribute to help solving the issue. I'm familiar with python, but I'm certainly not a master. However, maybe there's something I can help with. He forwarded me to you, so .. here I am ;)

fabosi avatar Mar 21 '16 07:03 fabosi

I want to share my workaround to use pillar data with unicode characters and properly write it to a file on a Windows minion.

  1. Do not enable the yaml_utf8 config on the master.
  2. Store your data as is in pillar
  3. Write your state with the py renderer
  4. Use encode/decode on your pilllar data to get the proper encoding

For example, if you want to configure a user's mercurial.ini

pillar:

owner:
    fullname: André Roberts

state:

#!py

def run():
    config = {}

    config['mercurial.ini'] = {
        'ini.options_present': [
            { 'name': 'C:/User/aroberts/mercurial.ini' },
            { 'sections':
                { 'ui':
                    { 'username': __pillar__['owner']['fullname'].decode('utf8').encode('iso-8859-1') }
                }
            }
        ]
    }

    return config

This way, no jinja/yaml rendering is done on the minion, thus avoiding all jinja/yaml encoding problems.

Enjoy!

otrempe avatar Oct 08 '16 18:10 otrempe

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Jul 10 '18 19:07 stale[bot]