skipping, while when-statement is ok.

14 views
Skip to first unread message

ahai...@gmail.com

unread,
Dec 20, 2014, 4:32:14 PM12/20/14
to ansible...@googlegroups.com
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!
Reply all
Reply to author
Forward
0 new messages