# skipping, while when-statement is ok.

**URL:** <https://forum.ansible.com/t/skipping-while-when-statement-is-ok/17121>\
**Category:** Ansible Project\
**Created:** [December 20, 2014, 9:32pm UTC](https://forum.ansible.com/t/skipping-while-when-statement-is-ok/17121 "2014-12-20T21:32:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahaitoute](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@ahaitoute](https://forum.ansible.com/u/ahaitoute)\
**Post date:** [December 20, 2014, 9:32pm UTC](https://forum.ansible.com/t/skipping-while-when-statement-is-ok/17121/1 "2014-12-20T21:32:14Z")

</div>

Hello,

I’ve got the following ansible code:

`

- name: check distro exists  
with\_items: distro  
stat: path=/var/www/cobbler/ks\_mirror/{{ item.name }}-{{ item.arch }}/images/pxeboot/initrd.img  
register: distro\_file  
when: distro is defined

- name: add distro to cobbler  
shell: cobbler import --name=“{{ item.name }}-{{ item.arch }}” --path=“{{ item.url }}” --arch=“{{ item.arch }}”  
with\_items:

- distro

- distro\_file  
when: distro is defined and not distro\_file.stat.exists  
notify:

- restart cobbler

- wait for cobbler

- sync cobbler

`

When the file /var/www/cobbler/ks\_mirror/{{ item.name }}-{{ item.arch }}/images/pxeboot/initrd.img doesn’t exist, the shell command must be executed. But when I run this code, I get the following output:

`

TASK: [cobbler | check distro exists] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [provisioning] =\> (item={‘url’: u’rsync://repository.rinis.net/centos\_6/os/x86\_64/', ‘arch’: ‘x86\_64’, ‘name’: ‘centos-6’}) =\> {“changed”: false, “item”: {“arch”: “x86\_64”, “name”: “centos-6”, “url”: “rsync://repository.rinis.net/centos\_6/os/x86\_64/”}, “stat”: {“exists”: false}}

TASK: [cobbler | add distro to cobbler] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [provisioning] =\> (item=distro)  
skipping: [provisioning] =\> (item=distro\_file)

`

It skippes the “add distro to cobbler” while it should run. Can someone help me to fix this issue.

Thanks!
