New at Ansible and still trying to get the hang of setting conditional 
based upon output.

I am setting Windows file shares with the below task. The initial run works 
fine; however, when you repeat the task, it fails stating that the shares 
already exist. How do I set a conditional that states if the network share 
already exists ignore, move on, rather than fail the run.

Task:

- name: Set File Shares 
  win_shell: |
    net share WebContent="E:\Inetpub\wwwroot" /Grant:Everyone,READ 
/Grant:OSC\ServerAdministrator,CHANGE
    net share LogFiles="F:\Inetpub\LogFiles" /Grant:Everyone,READ
    net share Indexes="C:\Indexes" /Grant:Everyone,READ 
/Grant:OSC\ServerAdministrator,CHANGE
    net share Components="C:\Component Services" /Grant:Everyone,READ 
/Grant:OSC\ServerAdministrator,CHANGE
    net share Resources="C:\Inetpub" /Grant:Everyone,READ 
/Grant:OSC\ServerAdministrator,CHANGE

Output:

STDOUT:

LogFiles was shared successfully.

STDERR:

The name has already been shared.

More help is available by typing NET HELPMSG 2118.

The name has already been shared.

More help is available by typing NET HELPMSG 2118.

The name has already been shared.

More help is available by typing NET HELPMSG 2118.

The name has already been shared.

More help is available by typing NET HELPMSG 2118.


MSG:

non-zero return code

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ee5cc554-c461-486f-88ca-13d18e1f940bn%40googlegroups.com.

Reply via email to