Ansible: Use variable for defining playbook hosts
<p>I have the following version installed: <strong>ansible 2.3.0 (devel 2131eaba0c)</strong></p>

<p>I want to specify my host variable as external variable and then use it in the <strong>playbook</strong> similar to this:</p>

<pre><code>hosts: "{{integration}}"
</code></pre>

<p>In my <strong>group_vars/all</strong> file I have the following defined variable:</p>

<pre><code>integration: "int60"
</code></pre>

<p>The <strong>host file</strong> looks like this:</p>

<pre><code>[int60] 
hostA

[int61]
hostB
</code></pre>

<p>Unfortunately this does not work. I also tried to define the <strong>host var</strong> in the following way:</p>

<pre><code>[integration]
127.0.0.1 ansible_host="{{ integration_env }}"
</code></pre>

<p>and have the integration_env specified in my <strong>group_vars/all</strong> file. In this case it seemed like it ran the tasks locally and not in the desired environment.</p>

<p>Is it possible to do something like this? I'd be open to whole new ways of doing this. The main goal is simply to define the host variable in a var file.</p>