Ansible 操作 windowws 中文亂碼問題解決辦法

亂碼原因是因爲 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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章