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