Skip to content

Instantly share code, notes, and snippets.

@d3athkai
Last active December 30, 2023 05:12
Show Gist options
  • Save d3athkai/5ae3fedd055fcaddf4bf979941a21a6e to your computer and use it in GitHub Desktop.
Save d3athkai/5ae3fedd055fcaddf4bf979941a21a6e to your computer and use it in GitHub Desktop.
Ansible and yum check-update return codes [rc]

Yum check-update return codes

When using yum check-update in Ansible Playbook, it may failed sometimes because of the following reasons:

  • yum check-update returns exit value of 100 if there are packages available for an update. Also returns a list of the packages to be updated in list format.
  • yum check-update returns 0 if no packages are available for update.
  • yum check-update returns 1 if an error occurred.

The easiest way is to use ignore_error: yes in your that task, but this will also cause other return codes to be ignored and your playbook will continue execute.

The better way is to add the following line:

  - shell: yum check-update  
    register: yum_result  
    failed_when: yum_result.rc not in [ 0, 100 ]  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment