--- - name: check version of ansible shell: pip3 show ansible | grep Version | cut -d ' ' -f 2 ignore_errors: true changed_when: false register: get_ansible_version - name: old ansible pip package removed pip: name: ansible state: absent executable: pip3 when: ansible_installed_version is version('2.10', '<') - name: ansible pip package pip: name: ansible state: latest executable: pip3