Skip to content

Ansible: Use errors="ignore" instead of skip

Another Ansible upgrade deprecation warning, which appears in Ansible 2.8:

TASK [send email] *************************************************************************************************************************************************************************************************************************************************************
[DEPRECATION WARNING]: Use errors="ignore" instead of skip. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

Found so many in the last time that I added a new Tag: Deprecation.

 

Back to business. What is going on ... I run the following task:

- name: send email
  mail:
    from: ...
    to: ...
    charset: utf8
    subject: ...
    body: ...
    attach: ...
  when: not lookup('first_found', dict(files = [ playbook_dir + '/' + '/mailsent.txt' ], skip = true))

I'm using this as a cheap way to only send an email once, and then the next task creates this file. Yes, there is a race condition, I'm aware of that. That's not the point here.

The "first_found" lookup will return the first found file out of a number of filenames specified as parameters. If none of the files in the list are found, this returns an error, which effectively stops the playbook. However there is the "skip" parameter, which turns the error into just an empty result. By using the "when: not" condition, this only sends the email when the specified file does not exist.

This "skip" parameter changes in upcoming Ansible versions, and is replaced by: errors="ignore". To make life not too easy, Ansible 2.8 throws the warning, but does not understand the new "errors" parameter, only the old "skip" parameter. So much fun!

As of today (2020-02-21), the documentation is only halfway updated. The examples already list the new "errors" parameter, the list of parameter still lists "skip". That's not useful ...

At some point in the future, the above Play needs to be changed to:

- name: send email
  mail:
    from: ...
    to: ...
    charset: utf8
    subject: ...
    body: ...
    attach: ...
  when: not lookup('first_found', dict(files = [ playbook_dir + '/' + '/mailsent.txt' ], errors="ignore"))

 

  • Twitter
  • Bookmark Ansible: Use errors="ignore" instead of skip at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Ansible: Use errors="ignore" instead of skip
  • Bloglines Ansible: Use errors="ignore" instead of skip
  • Technorati Ansible: Use errors="ignore" instead of skip
  • Fark this: Ansible: Use errors="ignore" instead of skip
  • Bookmark Ansible: Use errors="ignore" instead of skip at YahooMyWeb
  • Bookmark Ansible: Use errors="ignore" instead of skip at Furl.net
  • Bookmark Ansible: Use errors="ignore" instead of skip at reddit.com
  • Bookmark Ansible: Use errors="ignore" instead of skip at blinklist.com
  • Bookmark Ansible: Use errors="ignore" instead of skip at Spurl.net
  • Bookmark Ansible: Use errors="ignore" instead of skip at Simpy.com
  • Bookmark Ansible: Use errors="ignore" instead of skip at blogmarks
  • Bookmark Ansible: Use errors="ignore" instead of skip with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options