ansible fail if condition fails

You can configure ansible to fail on a condition with:

  pre_tasks:
    - name: Fail if OS is not Centos
      fail:
        msg: "The playbook only supports Centos"
      when: "ansible_distribution != 'CentOS'