Skip to content

Instantly share code, notes, and snippets.

@enisozgen
Last active November 7, 2023 18:45
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enisozgen/0a61358b8101b7a08051fe121d5bbf01 to your computer and use it in GitHub Desktop.
Save enisozgen/0a61358b8101b7a08051fe121d5bbf01 to your computer and use it in GitHub Desktop.
ansible tasks that Checks if a program exists from a Bash script
- name: Check is rvm installed
shell: command -v rvm >/dev/null 2>&1
register: is_rvm_exist
ignore_errors: yes
- debug: msg="{{ is_rvm_exist.rc }}" # it returns rc 1
- debug: var=is_rvm_exist
- name: Check is ls installed
shell: command -v ls >/dev/null 2>&1
register: is_ls_exist
ignore_errors: yes
- debug: msg="{{ is_ls_exist.rc }}" # it returns rc 0
- debug: var=is_ls_exist
@deogracia
Copy link

Thanks!
I always forgot bash "command".

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