Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed_when directive does not accept lists #13905

Closed
profhase opened this issue Jan 15, 2016 · 4 comments

Comments

Projects
None yet
6 participants
@profhase
Copy link

commented Jan 15, 2016

Issue Type:

Bug Report

Ansible Version:

2.0.0.1

Environment:

ubuntu 14.04

Summary:

The failed_when module does not support lists anymore

Steps To Reproduce:
- hosts: localhost
  tasks:
    - name: hello
      command: "/dev/null"
      register: myresult
      failed_when:
        - "myresult == 1"
        - "myresult == 2"
Expected Results:

pass

Actual Results:

ERROR! The field 'failed_when' is supposed to be a string type, however the incoming data structure is a <class 'ansible.parsing.yaml.objects.AnsibleSequence'>

@bcoca bcoca changed the title failed_when module does not accept lists failed_when directive does not accept lists Jan 18, 2016

@bcoca bcoca added the bug_report label Jan 18, 2016

@bcoca bcoca added this to the stable-2.0 milestone Jan 18, 2016

@bcoca

This comment has been minimized.

Copy link
Member

commented Jan 18, 2016

need to check all 'when's to make sure they all behave this way

@rossey

This comment has been minimized.

Copy link

commented Feb 17, 2016

@profhase this is a work around I've implemented

- hosts: localhost
  tasks:
    - name: hello
      command: "/dev/null"
      register: myresult
  failed_when: "{{ item }}"
  with_items:
    - "myresult == 1"
    - "myresult == 2"

@jimi-c jimi-c added the in progress label Mar 6, 2016

bcoca added a commit to bcoca/ansible that referenced this issue Mar 9, 2016

make all conditionals lists
this brings them to equivalence with when:
fixes ansible#13905

@bcoca bcoca closed this in #14833 Mar 9, 2016

@jimi-c jimi-c removed the in progress label Mar 9, 2016

@bcoca

This comment has been minimized.

Copy link
Member

commented Mar 9, 2016

so this should be fixed by merge, but just wanted to point out that the condition in the example is a logic error as the list is an implicit 'and' (always was).

bcoca added a commit that referenced this issue Mar 9, 2016

make all conditionals lists
this brings them to equivalence with when:
fixes #13905
@karniemi

This comment has been minimized.

Copy link

commented May 16, 2016

While there, can you please document this list-feature for failed_when? I'm pretty sure I read somewhere that the items are combined using 'or' ...but lacking official docs means it's non-specified behavior altogether.

Here one example from ansible team telling that the list is combined using 'or': https://groups.google.com/forum/#!topic/ansible-project/cIaQTmY3ZLE

@ansibot ansibot added bug and removed bug_report labels Mar 7, 2018

@ansible ansible locked and limited conversation to collaborators Apr 25, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.