<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">vmware_guest</p>
<p dir="auto">It's also possible this is the root issue for this one :  <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="206308324" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/21161" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/21161/hovercard" href="https://github.com/ansible/ansible/issues/21161">#21161</a></p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.4.0.0
  config file = /Users/spollock/ansible/fs-vmw-control/ansible.cfg
  configured module search path = [u'/Users/spollock/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Python/2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]
"><pre class="notranslate"><code class="notranslate">ansible 2.4.0.0
  config file = /Users/spollock/ansible/fs-vmw-control/ansible.cfg
  configured module search path = [u'/Users/spollock/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Python/2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]

</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<h5 dir="auto">SUMMARY</h5>

<p dir="auto">Although I am setting a static mac address with vmware_guest, it only works if this mac address is not already used somewhere on the vCenter.  I even try to override by setting "force: yes" and it behaves the same.  There is no error message given.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<p dir="auto">Try to set the mac using vmware_guest when the mac address already exists, it will change to automatic and assign a random mac.  If it does not exist, it works.</p>
<p dir="auto">force = yes has no effect.</p>

<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
- name: Launching machine &quot;{{vcpreptargetkit}}{{vcprepelement[1:3]}}-{{vcpreptemplate}}&quot;
  vmware_guest:
    validate_certs: no
    hostname: &quot;{{ vcenterhostname }}&quot;
    username: &quot;{{ vcusername }}&quot;
    password: &quot;{{ vcpassword }}&quot;
    datacenter: &quot;{{ vcdatacenter }}&quot;
    cluster: &quot;{{ vccluster }}&quot;
    template: &quot;source template&quot;
    name: &quot;machine name&quot;
    networks: 
        -name: &quot;some port group&quot;
          mac: &quot;00:50:56:00:01:01&quot;
    state: poweredoff
    force: yes
  delegate_to: localhost

"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">Launching machine "{{vcpreptargetkit}}{{vcprepelement[1:3]}}-{{vcpreptemplate}}"</span>
  <span class="pl-ent">vmware_guest</span>:
    <span class="pl-ent">validate_certs</span>: <span class="pl-s">no</span>
    <span class="pl-ent">hostname</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ vcenterhostname }}<span class="pl-pds">"</span></span>
    <span class="pl-ent">username</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ vcusername }}<span class="pl-pds">"</span></span>
    <span class="pl-ent">password</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ vcpassword }}<span class="pl-pds">"</span></span>
    <span class="pl-ent">datacenter</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ vcdatacenter }}<span class="pl-pds">"</span></span>
    <span class="pl-ent">cluster</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ vccluster }}<span class="pl-pds">"</span></span>
    <span class="pl-ent">template</span>: <span class="pl-s"><span class="pl-pds">"</span>source template<span class="pl-pds">"</span></span>
    <span class="pl-ent">name</span>: <span class="pl-s"><span class="pl-pds">"</span>machine name<span class="pl-pds">"</span></span>
    <span class="pl-ent">networks</span>: 
        -<span class="pl-ent">name</span>: <span class="pl-s"><span class="pl-pds">"</span>some port group<span class="pl-pds">"</span></span>
          <span class="pl-ent">mac</span>: <span class="pl-s"><span class="pl-pds">"</span>00:50:56:00:01:01<span class="pl-pds">"</span></span>
    <span class="pl-ent">state</span>: <span class="pl-s">poweredoff</span>
    <span class="pl-ent">force</span>: <span class="pl-s">yes</span>
  <span class="pl-ent">delegate_to</span>: <span class="pl-s">localhost</span>

</pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">Should have set the mac regardless.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">Doesn't set the mac</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="No error messages are generated."><pre class="notranslate"><code class="notranslate">No error messages are generated.
</code></pre></div>
<p dir="auto">Hi, we are trying to make use of with_items with include but have found that variables are not being expanded inside the include. I have constructed a simple test case:</p>
<p dir="auto">inventory</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="localhost"><pre class="notranslate"><code class="notranslate">localhost
</code></pre></div>
<p dir="auto">host_vars/localhost</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
---
test_items:
  - name: test1
    property: 1
  - name: test2
    property: 2"><pre class="notranslate">---
<span class="pl-ent">test_items</span>:
  - <span class="pl-ent">name</span>: <span class="pl-s">test1</span>
    <span class="pl-ent">property</span>: <span class="pl-c1">1</span>
  - <span class="pl-ent">name</span>: <span class="pl-s">test2</span>
    <span class="pl-ent">property</span>: <span class="pl-c1">2</span></pre></div>
<p dir="auto">main.yml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
---
- hosts: localhost
  gather_facts: no
  vars:
    testing: $test_items
  tasks:
  - name: debug in main
    debug: msg={{ item.name }}
    with_items: ${testing} 

  - include: tasks/debug.yml item=$item
    with_items: ${testing} "><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
  <span class="pl-ent">gather_facts</span>: <span class="pl-s">no</span>
  <span class="pl-ent">vars</span>:
    <span class="pl-ent">testing</span>: <span class="pl-s">$test_items</span>
  <span class="pl-ent">tasks</span>:
  - <span class="pl-ent">name</span>: <span class="pl-s">debug in main</span>
    <span class="pl-ent">debug</span>: <span class="pl-s">msg={{ item.name }}</span>
    <span class="pl-ent">with_items</span>: <span class="pl-s">${testing} </span>

  - <span class="pl-ent">include</span>: <span class="pl-s">tasks/debug.yml item=$item</span>
    <span class="pl-ent">with_items</span>: <span class="pl-s">${testing} </span></pre></div>
<p dir="auto">task/debug.yml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
---
- name: debug in the task
  debug: msg={{ item.name }}"><pre class="notranslate">---
- <span class="pl-ent">name</span>: <span class="pl-s">debug in the task</span>
  <span class="pl-ent">debug</span>: <span class="pl-s">msg={{ item.name }}</span></pre></div>
<p dir="auto">running the playbook results in:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="% ansible-playbook -i inventory -c local main.yml -v                                                                                                                                                                   

PLAY [localhost] **************************************************************

TASK: [debug in main] *********************************************************
ok: [localhost] =&gt; (item={'property': 1, 'name': 'test1'}) =&gt; {&quot;item&quot;: {&quot;name&quot;: &quot;test1&quot;, &quot;property&quot;: 1}, &quot;msg&quot;: &quot;test1&quot;}
ok: [localhost] =&gt; (item={'property': 2, 'name': 'test2'}) =&gt; {&quot;item&quot;: {&quot;name&quot;: &quot;test2&quot;, &quot;property&quot;: 2}, &quot;msg&quot;: &quot;test2&quot;}

TASK: [debug in the task] *****************************************************
ok: [localhost] =&gt; (item=$test_items) =&gt; {&quot;item&quot;: &quot;$test_items&quot;, &quot;msg&quot;: &quot;{{item.name}}&quot;}

PLAY RECAP ********************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">% ansible-playbook -i inventory -c local main.yml -v                                                                                                                                                                   

PLAY [localhost] **************************************************************

TASK: [debug in main] *********************************************************
ok: [localhost] =&gt; (item={'property': 1, 'name': 'test1'}) =&gt; {"item": {"name": "test1", "property": 1}, "msg": "test1"}
ok: [localhost] =&gt; (item={'property': 2, 'name': 'test2'}) =&gt; {"item": {"name": "test2", "property": 2}, "msg": "test2"}

TASK: [debug in the task] *****************************************************
ok: [localhost] =&gt; (item=$test_items) =&gt; {"item": "$test_items", "msg": "{{item.name}}"}

PLAY RECAP ********************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0
</code></pre></div>
<p dir="auto">the debug in main expands the variable correctly but in the include it is just the literal string.</p>