--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/f26fe725-e8c7-40f7-92dd-6a2cba3d32ec%40googlegroups.com.
Your `when` statement, needs to be indented to the same level as `win_copy`, not the same level as `dest`. Also it needs to be the lowercased `when`
On Wed, Sep 18, 2019 at 11:04 AM Tom Donnly <tom....@gmail.com> wrote:
Hello all,--I am trying to do a conditional based on the output of a win_shell. When I run this it's as if it doesn't see the conditional and copies to to all inventory not just what is coming back as True. Any ideas?---- hosts: alltasks:- name: Run multi-lined shell commandswin_shell: |if (Test-Path “HKLM:\Software\Microsoft\Microsoft SQL Server\Instance Names\SQL”) { write-host “True” } Else { write-host “False” }register: results- name: Process win_shell outputset_fact:output: "{{ results.stdout }}"- win_copy:src: files/dest: c:\supportWhen: ansible_facts['results.stdout'] == "True"
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansibl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/f26fe725-e8c7-40f7-92dd-6a2cba3d32ec%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/558e8115-f593-481a-a660-6ad035f9c7bf%40googlegroups.com.
`results.stdout` is not a literal variable name. Instead what you are likely looking for is:when: results.stdout|trim == 'True'or since you use `set_fact` in between, it could also be:when: output|trim == 'True'
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/558e8115-f593-481a-a660-6ad035f9c7bf%40googlegroups.com.