When condition is failing in windows ansible

10 views
Skip to first unread message

Uppara venkat

unread,
Mar 19, 2020, 4:22:29 AM3/19/20
to ansible...@googlegroups.com
Hi all,

I have written below task to copy a file if it is 64-bit windows OS. 

- name:
  win_shell: 'wmic os get osarchitecture |  findstr "bit"'
  register: result
- debug: var=result.stdout_lines  

- name:
  win_copy:
   src='{{package_PATH}}/vim25.zip'
   dest='{{ vim25_PATH }}/vmware/'
   remote_src=yes
  when: result.stdout_lines == '64-bit'

while executing  task it's skipping even condition is true.

out put as below:

skipping: [172.31.27.224] => {
    "changed": false,
    "skip_reason": "Conditional result was False"
}


Can any one help me to fix this issue?

Stefan Hornburg (Racke)

unread,
Mar 19, 2020, 4:31:55 AM3/19/20
to ansible...@googlegroups.com
1. use Ansible facts to determine OS details (ansible_architecture)
2. stdout_lines is a list so a string match is futile, try stdout or stdout_lines[0]

Regards
Racke

>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAFMhZ_%2B4oF0BD10fcX_3r-CnsNvsV%3DRT2h7_wSAnu%2BBkBmT%3Dug%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAFMhZ_%2B4oF0BD10fcX_3r-CnsNvsV%3DRT2h7_wSAnu%2BBkBmT%3Dug%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc
Reply all
Reply to author
Forward
0 new messages