Answer the question
In order to leave comments, you need to log in
How to remove bugs on stdout output in Ansible?
I'm making a playbook to activate windows via local kms. One of the tasks is getting information about the installed license from the command line:
- name: Information about license
win_command: cscript {{ ansible_env.windir }}\System32\slmgr.vbs -dlv
register: info_out
- debug:
var: info_out.stdout_lines
Answer the question
In order to leave comments, you need to log in
Found a couple of options for solving the correct output of VBS
Unfortunately, both options with intermediate output to a file
- name: Information about license for Windows
win_shell: |
# variant 1
Start-Process -Wait -RedirectStandardOutput C:\111 -FilePath cscript -ArgumentList 'slmgr.vbs','-dlv'
Get-Content C:\111 -Encoding OEM
# variant 2
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("cp866")
cscript slmgr.vbs -dlv > c:\222
Get-Content C:\222 -Encoding Unicode
register: infowin_out
args:
chdir: '{{ ansible_env.windir }}\System32\'
no_profile: yes
- debug: var=infowin_out
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question