# Run task if other has not been run

**URL:** <https://forum.ansible.com/t/run-task-if-other-has-not-been-run/35325>\
**Category:** Ansible Project\
**Created:** [June 10, 2021, 11:28am UTC](https://forum.ansible.com/t/run-task-if-other-has-not-been-run/35325 "2021-06-10T11:28:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Polenius\_Ande](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@Robert\_Polenius\_Ande](https://forum.ansible.com/u/Robert_Polenius_Ande)\
**Post date:** [June 10, 2021, 11:28am UTC](https://forum.ansible.com/t/run-task-if-other-has-not-been-run/35325/1 "2021-06-10T11:28:17Z")

</div>

Hi!  
I got a problem that I can’t seem to find a solution to on Google.  
I am by the way very new to using Ansible.

My task looks like below:

- name: Copy file if server in GROUP1. Register output to config\_copied  
win\_copy:  
src: xxx  
dest: yyy  
remote\_src: True  
when: “‘GROUP1’ in group\_names”  
register: config\_copied

- name: Copy file if server in GROUP2. Register output to config\_copied  
win\_copy:  
src: zzz  
dest: yyy  
remote\_src: True  
when: “‘GROUP2’ in group\_names”  
register: config\_copied

##Default config

- name: Copy default file if no group specific file has been copied. Register output to default\_config\_copied  
win\_copy:  
src: ccc  
dest: yyy  
remote\_src: True  
when: config\_copied is skipped  
register: default\_config\_copied

I need to copy a file which is different depending on the group membership.  
If no group specific file has been copied (or gotten OK due to up to date) the default config should be copied.

The problem is, if the GROUP1 config gets copied and output is registred to config\_copied, then the next step evaluates, the server is NOT a member of GROUP2 and therefore it registers “is skipped” to config\_copied.  
So even tho the group specific file has been copied config\_copied gets overwritten by is skipped.

Does anyone have a solution to my problem? Using different variables for each step wouldn’t work as there will be 40+ groups.

Thanks in advance!
