- name: Get list of packages to install from bindep command: "{{ bindep_run }}" register: bindep_output failed_when: false - name: Install distro packages from bindep package: name: "{{ bindep_output.stdout_lines }}" state: present become: yes when: bindep_output.stdout_lines - name: Check that packages are installed command: "{{ bindep_run }}" register: bindep_final_check # Ignore errors then fail later so that we can give a better error message failed_when: false - name: Fail if we cannot install all packages fail: msg: "bindep failed to install from {{ bindep_file }} - {{ bindep_final_check.stdout }}" when: bindep_final_check is failed