title: Check if a list contains an item in Ansible
body: <p>I'm trying to check if the version supplied is a valid supported version. I've set the list of acceptable versions in a variable, and I want to fail out of the task if the supplied version is not in the list. However, I'm unsure of how to do that.</p>
  
  <pre><code>#/role/vars/main.yml
  ---
    acceptable_versions: [2, 3, 4]
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#/role/tasks/main.yml
  ---
    - fail: 
        msg: "unsupported version"
        with_items: "{{acceptable_versions}}"
        when: "{{item}} != {{version}}"
  
    - name: continue with rest of tasks...
  </code></pre>
  
  <p>Above is sort of what I want to do, but I haven't been able to figure out if there's a one line way to construct a "list contains" call for the fail module.</p>