debugMinor
Ansible playbook fails with: no test named 'success'
Viewed 0 times
failssuccesswithnamedplaybooktestansible
Problem
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 context from the playbook is:
The output of
and
and
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?
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
^ hereThe context from the playbook is:
tasks:
- 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 successThe output of
dpkg-query -W -f='${Status}' aptitude | grep 'install ok installed' is:install ok installedand
ansible --versionansible 2.2.1.0
config file = /mnt/c/source/richardslater/workstation-setup/wsl/plays/ansible.cfg
configured module search path = Default w/o overridesand
pip show jinja2Name: 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: armin.ronacher@active-4.com
License: BSD
Location: /usr/lib/python2.7/dist-packages
Requires: MarkupSafeI'm not entirely sure how it ever worked, either that or something changed since I built this playbook, any ideas on how to fix?
Solution
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
If you don't want to stop on task, but still to have an idea how it went, you should use
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.Context
StackExchange DevOps Q#8071, answer score: 1
Revisions (0)
No revisions yet.