Ansible 操作 windowws 中文乱码问题解决办法

时间:2018-05-02 15:57:45   收藏:0   阅读:1827
乱码原因是因为 Linux 和 Windows 编码不一致所导致

修改环境变量即可


设置环境变量为 utf-8

ansible win_test -m win_shell -a 'Set-Item -Path env:PYTHONIOENCODING -Value "utf-8"; python d:\test\stat.py'

# playbook 
---
- hosts: win_test
  gather_facts: no
  tasks:
    - name: run Python script with utf-8 output
      win_command: Python.exe d:\test\stat.py
      environment:
        PYTHONIOENCODING: utf-8


评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!