Role does not take in consideration conditional "when" at with_items

27 views
Skip to first unread message

Adrian Paraschiv

unread,
Nov 3, 2015, 2:16:05 PM11/3/15
to Ansible Project
Hi all,

I have a role with some shell tasks + 2 include: of some yaml files that also contain shell tasks. the first tasks are skipped as per condition but the include: are not
Here is the small playbook:
---
- name: test eden deploy
  hosts: ACEDV-LM-01
  sudo: True
  roles:
    - { role: check_eden, when: ansible_hostname != "ACEDV-LM-01", tags: pre, param: pre }
 
Here is the role (partial):

- name: get the date for naming purpose
  shell: date +%Y%m%d-%HH%MM%SS
  register: dateext
- include: /etc/ansible/roles/check_nagios/tasks/main.yml
- include: /etc/ansible/roles/check_nagios/tasks/main.yml

The first task is skipped plus some other from the include but the rest are not:
Here is the error:

fatal: [ACEDV-LM-01] => with_items expects a list or a set

This error is from the include that uses some with_items: "{{ variable.stdout_lines }}" in a shell tasks but they are not skipped.

Why aren't all the tasks skipped ???
How to do it right ?

Ansible version is 1.9.4 on a redhat 6.7 system
Thank you
Adi
Reply all
Reply to author
Forward
0 new messages