I have an Ansible Playbook that is used to configure WSL on my Windows Laptop, having rebuilt my laptop recently I needed to run the playbook again, however it is failing with the following message:

The conditional check 'aptitude_installed is success' failed. The error was: no test named 'success'
  line 1

The error appears to have been in '/mnt/c/source/richardslater/workstation-setup/wsl/plays/wsl.yml': line 15, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:

  - name: ensure aptitude is installed
    ^ here

The context from the playbook is:

- name: check if aptitude is installed
  shell: dpkg-query -W -f='${Status}' aptitude | grep 'install ok installed'
  register: aptitude_installed
  failed_when: no
  changed_when: no

- name: ensure aptitude is installed
  command: apt-get -y install aptitude warn=False
  when: aptitude_installed is success

The output of dpkg-query -W -f='${Status}' aptitude | grep 'install ok installed' is:

install ok installed

and ansible --version

  config file = /mnt/c/source/richardslater/workstation-setup/wsl/plays/ansible.cfg
  configured module search path = Default w/o overrides

and pip show jinja2

Name: Jinja2
Version: 2.8
Summary: A small but fast and easy to use stand-alone template engine 
written in pure python.
Home-page: http://jinja.pocoo.org/
Author: Armin Ronacher
Author-email: [email protected]
License: BSD
Location: /usr/lib/python2.7/dist-packages
Requires: MarkupSafe

I'm not entirely sure how it ever worked, either that or something changed since I built this playbook, any ideas on how to fix?

3 Answers 3


You use pretty old ansible, maybe worth to try a new one. Although tests "succeeded" and "success" should be in 2.2 too.

But main problem I think it's failed_when: no in your task. It makes test when: aptitude_installed is success completely useless, it will be always true because failed_when: no marks all tasks as successful.

If you don't want to stop on task, but still to have an idea how it went, you should use ignore_errors: true, not failed_when: no. With ignore_errors: true you can both continue your playbook and inspect a real tasks results.


I do not have any clue of how your code once ran and produced the expected result. The when clause cannot be executed (as you found out from the error) and would anyway produce the reverse result you are expecting if I follow the underlying logic (install the package only when it is already installed). Moreover, your are in this simple case far from good ansible practice.

You should avoid using shell and command when there is an existing module that already does the job and manages idempotency for you. In present case, you can use the agnostic package module or the specific apt (which I will prefer in my example since your playbook targets an Ubuntu install on wsl and a debian/ubuntu package anyway).

  - name: Ensure aptitude is installed
      name: aptitude
      state: present

The above will simply install aptitude unless it is already there in a simple easy single task.


I got this error also and ended up here, reason is I think I was using another version of ansible on another computer so I changed the syntax to when: sometest is success because I got warnings before. Now on this computer where I run version apparently this does not work at all, so I fell back on when: sometest|success instead and now it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.