About character judgment of register.stdout of win_shell
good evening
Please tell me how to execute when the value of register.stdout of win_shell is 1.
ansible version:
# ansible --version
ansible [core 2.11.0]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/rh/rh-python38/root/usr/local/lib/python3.8/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/rh/rh-python38/root/usr/local/bin/ansible
python version = 3.8.6 (default, Oct 27 2020, 09:13:12) [GCC 9.3.1 20200408 (Red Hat 9.3.1-2)]
jinja version = 3.0.1
libyaml = True
playbook:
- name: windows test
hosts: windows
gather_facts: no
tasks:
- name: windows stdout test
win_shell: echo 1
register: result
- debug: var=result.stdout
- debug: msg="{{ result.stdout }}"
when: result.stdout == "1"
Execution result:
PLAY [windows test] ************************************************************
TASK [windows stdout test] *****************************************************
changed: [win01]
TASK [debug] *******************************************************************
ok: [win01] =>
result.stdout: |-
1
TASK [debug] *******************************************************************
skipping: [win01]
PLAY RECAP *********************************************************************
win01 : ok=2 changed=1 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
[When: result.stdout == "1"] does not become True and skips.
How can I do this?