# Setting Conditionals with Output

**URL:** <https://forum.ansible.com/t/setting-conditionals-with-output/33586>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [August 11, 2020, 3:00pm UTC](https://forum.ansible.com/t/setting-conditionals-with-output/33586 "2020-08-11T15:00:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Hixon](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@James\_Hixon](https://forum.ansible.com/u/James_Hixon)\
**Post date:** [August 11, 2020, 3:00pm UTC](https://forum.ansible.com/t/setting-conditionals-with-output/33586/1 "2020-08-11T15:00:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [August 12, 2020, 5:45am UTC](https://forum.ansible.com/t/setting-conditionals-with-output/33586/2 "2020-08-12T05:45:12Z")

</div>

Hi,

Perhaps using the module which does this, you’ll have the idempotence 😉

[https://docs.ansible.com/ansible/latest/modules/win\_share\_module.html](https://docs.ansible.com/ansible/latest/modules/win_share_module.html)

Regars,

JYL

---

<div class="post-metadata">

**Author:** ![James\_Hixon](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@James\_Hixon](https://forum.ansible.com/u/James_Hixon)\
**Post date:** [August 12, 2020, 12:12pm UTC](https://forum.ansible.com/t/setting-conditionals-with-output/33586/3 "2020-08-12T12:12:08Z")

</div>

JYL,

Appreciate the recommendation. I should have mentioned that the Windows OS is 2008r2. I did try this module before submitting and per the win\_share module docs and error message after run, this OS is not supported by the win\_share module.

James
