title: Run an Ansible task only when the hostname contains a string
body: <p>I have multiple tasks in a role as follows. I do not want to create another <code>yml</code> file to handle this task. I already have an include for the web servers, but a couple of our Perl servers require some web packages to be installed.</p>
  
  <pre><code>- name: Install Perl Modules
    command: &lt;command&gt;
    with_dict: perl_modules
  
  - name: Install PHP Modules
    command: &lt;command&gt;
    with_dict: php_modules
    when: &lt;Install php modules only if hostname contains the word "batch"&gt;
  </code></pre>
  
  <p>Host inventory file</p>
  
  <pre><code>[webs]
  web01
  web02
  web03
  
  [perl]
  perl01
  perl02
  perl03
  perl-batch01
  perl-batch02
  </code></pre>