ansible 操作 windowws 中文亂碼問(wèn)題解決辦法
亂碼原因是因?yàn)?Linux 和 Windows 編碼不一致所導(dǎo)致,修改環(huán)境變量即可
設(shè)置環(huán)境變量為 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
浙公網(wǎng)安備 33010602011771號(hào)