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

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">???</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.6.0 (skipped_false 39251fc27b) last updated 2018/02/10 00:32:41 (GMT +200)
  config file = None
  configured module search path = ['/home/nikos/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/nikos/Projects/ansible/lib/ansible
  executable location = /home/nikos/Projects/ansible/bin/ansible
  python version = 3.6.4 (default, Jan  5 2018, 02:35:40) [GCC 7.2.1 20171224]"><pre class="notranslate"><code class="notranslate">ansible 2.6.0 (skipped_false 39251fc27b) last updated 2018/02/10 00:32:41 (GMT +200)
  config file = None
  configured module search path = ['/home/nikos/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/nikos/Projects/ansible/lib/ansible
  executable location = /home/nikos/Projects/ansible/bin/ansible
  python version = 3.6.4 (default, Jan  5 2018, 02:35:40) [GCC 7.2.1 20171224]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">Default</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Arch linux latest, tasks run against localhost</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">It is not possible to define task vars from a dict variable</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- hosts: localhost
  tasks:
    - set_fact:
        dict: {'key': 'value'}
    - debug:
        msg: Test
      vars: &quot;{{ dict }}&quot;"><pre class="notranslate">- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">set_fact</span>:
        <span class="pl-ent">dict</span>: <span class="pl-s">{'key': 'value'}</span>
    - <span class="pl-ent">debug</span>:
        <span class="pl-ent">msg</span>: <span class="pl-s">Test</span>
      <span class="pl-ent">vars</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ dict }}<span class="pl-pds">"</span></span></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">The second task should be executed successfully and the dict's contents should become available as variables in the context of the task.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR! Vars in a Task must be specified as a dictionary, or a list of dictionaries

The error appears to have been in '/home/nikos/Projects/playbook.yml': line 8, column 9, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

      vars:
        - dict
        ^ here
"><pre class="notranslate"><code class="notranslate">ERROR! Vars in a Task must be specified as a dictionary, or a list of dictionaries

The error appears to have been in '/home/nikos/Projects/playbook.yml': line 8, column 9, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

      vars:
        - dict
        ^ here

</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">lib/ansible/playbook/base.py</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.0.0
  config file =
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.0.0
  config file =
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">I am trying to set the vars for either a block: or an include_role: from a dictionary.</p>
<p dir="auto">I get one of these messages (depending on the case):<br>
ERROR! Vars in a Block must be specified as a dictionary, or a list of dictionaries<br>
ERROR! Vars in a IncludeRole must be specified as a dictionary, or a list of dictionaries</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- set_fact:
    _T_m3_inv_vars:
        one_setting: &quot;{{ some_other_var1 |mandatory }}&quot;
        two_setting: &quot;{{ some_other_var2 |mandatory }}&quot;

- block:
    - debug: msg=&quot;YYYYYYYY&quot;
  vars: &quot;{{ _T_m3_inv_vars }}&quot;

- include_role:
      name: &quot;some_nice_role&quot;
      static:  yes
      private: yes
  vars: &quot;{{ _T_m3_inv_vars }}&quot;
"><pre class="notranslate"><code class="notranslate">- set_fact:
    _T_m3_inv_vars:
        one_setting: "{{ some_other_var1 |mandatory }}"
        two_setting: "{{ some_other_var2 |mandatory }}"

- block:
    - debug: msg="YYYYYYYY"
  vars: "{{ _T_m3_inv_vars }}"

- include_role:
      name: "some_nice_role"
      static:  yes
      private: yes
  vars: "{{ _T_m3_inv_vars }}"

</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">I would expect a similar result as having done the following</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- block:
    - debug: msg=&quot;YYYYYYYY&quot;
  vars:
        one_setting: &quot;{{ some_other_var1 |mandatory }}&quot;
        two_setting: &quot;{{ some_other_var2 |mandatory }}&quot;

- include_role:
      name: &quot;some_nice_role&quot;
      static:  yes
      private: yes
  vars:
        one_setting: &quot;{{ some_other_var1 |mandatory }}&quot;
        two_setting: &quot;{{ some_other_var2 |mandatory }}&quot;"><pre class="notranslate"><code class="notranslate">- block:
    - debug: msg="YYYYYYYY"
  vars:
        one_setting: "{{ some_other_var1 |mandatory }}"
        two_setting: "{{ some_other_var2 |mandatory }}"

- include_role:
      name: "some_nice_role"
      static:  yes
      private: yes
  vars:
        one_setting: "{{ some_other_var1 |mandatory }}"
        two_setting: "{{ some_other_var2 |mandatory }}"
</code></pre></div>
<p dir="auto">This is because I am indeed passing a dictionary to the vars: setting.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">One of these messages (obtained by running the previous snippets separatellyI<br>
ERROR! Vars in a Block must be specified as a dictionary, or a list of dictionaries<br>
ERROR! Vars in a IncludeRole must be specified as a dictionary, or a list of dictionaries</p>