I
I
Il-DA-R2020-03-04 11:21:20
Ansible
Il-DA-R, 2020-03-04 11:21:20

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

Unfortunately, it displays krakozyabry:
5e5f649f4f5d7702515984.png
How to win, who knows?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxKozlov, 2020-03-05
@MaxKozlov

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 question

Ask a Question

731 491 924 answers to any question