- block: - name: Verify Python3 import command: python3 -c "from ipapython.version import NUM_VERSION" register: py3test failed_when: False - name: Set python interpreter to 3 set_fact: ansible_python_interpreter: "/usr/bin/python3" when: py3test.rc == 0 - name: Set python interpreter to 2 set_fact: ansible_python_interpreter: "/usr/bin/python2" when: py3test.failed or py3test.rc != 0