Re-apply #28134 (pillar unicode conversion)
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.
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 ;)
I want to share my workaround to use pillar data with unicode characters and properly write it to a file on a Windows minion.
- Do not enable the
yaml_utf8config on the master. - Store your data as is in pillar
- Write your state with the py renderer
- 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!
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.