i trying write playbook execute tasks if package installed on hosts.
is possible register output command module , run tasks depending upon exit status of command ?
you on right path. if httpd doesnt exist, playbook execution fail. can use ignore_errors continue execution , run subsequent tasks based on return code of httpd_result. have given example below:
- hosts: localhost tasks: - command: "which httpd" register: httpd_result ignore_errors: true - debug: msg="found http" when: httpd_result.rc == 0 - debug: msg="not found httpd" when: httpd_result.rc!=0
here, instead of debug statements, can put whatever conditional tasks need run. hope helps.
Comments
Post a Comment