Skip to content

Instantly share code, notes, and snippets.

@polster
Created April 24, 2015 05:15
Show Gist options
  • Save polster/76441b57b28adb89aac1 to your computer and use it in GitHub Desktop.
Save polster/76441b57b28adb89aac1 to your computer and use it in GitHub Desktop.
How to check via Ansible if binary is installed
- name: Register maven installation status
command: which mvn
changed_when: false
failed_when: false
register: mvn_installed
- name: Check maven installation status
fail:
msg: "Maven appears to be missing, install first"
when: mvn_installed|failed
@boxrick
Copy link

boxrick commented Feb 4, 2019

A small update on this for people who may want a more current working version:

- name: Check if gsutil is installed
  command: which gsutil
  changed_when: false
  failed_when: gsutil_installed.rc not in [0,1]
  register: gsutil_installed

- name: Return fail if it is not installed
  fail:
    msg: "GSutil is not installed, install first"
  when: gsutil_installed.rc not in [ 0 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment