<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">vars_plugins</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ dpkg -l ansible
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  ansible        2.2.0.0-1ppa all          A radically simple IT automation 

$ ansible --version
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">$ dpkg -l ansible
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  ansible        2.2.0.0-1ppa all          A radically simple IT automation 

$ ansible --version
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Working on creating a vars plugin and discovered that in 2.2.0.0, the plugin is not getting any group vars. Downgrading to <strong>2.1.0.0</strong>, and the plugin can get data via <code class="notranslate">host.get_group_vars()</code>. I think this is potentially related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="149709510" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/15493" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/15493/hovercard" href="https://github.com/ansible/ansible/issues/15493">#15493</a></p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">Simple single host inventory with the following <code class="notranslate">group_vars/all</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test:
  - a"><pre class="notranslate"><code class="notranslate">test:
  - a
</code></pre></div>
<p dir="auto">Create the following simple vars_plugin at <code class="notranslate">vars_plugins</code> in the root of my working directory:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from __future__ import (absolute_import, division, print_function)
__metaclass__ = type


class VarsModule(object):

    &quot;&quot;&quot;
    Loads variables for groups and / or hosts

    &quot;&quot;&quot;

    def __init__(self, inventory):
        self.inventory = inventory
        self.inventory_basedir = inventory.basedir()

    def append_test(self, groupvars):
        results = {}
        if 'test' in groupvars:
            results.update({'test_plugin': 'yes'})

        return results

    def get_host_vars(self, host, vault_password=None):
        &quot;&quot;&quot; Get host specific variables. &quot;&quot;&quot;
        return self.append_test(host.get_group_vars())"><pre class="notranslate"><span class="pl-k">from</span> __future__ <span class="pl-k">import</span> (<span class="pl-s1">absolute_import</span>, <span class="pl-s1">division</span>, <span class="pl-s1">print_function</span>)
<span class="pl-s1">__metaclass__</span> <span class="pl-c1">=</span> <span class="pl-s1">type</span>


<span class="pl-k">class</span> <span class="pl-v">VarsModule</span>(<span class="pl-s1">object</span>):

    <span class="pl-s">"""</span>
<span class="pl-s">    Loads variables for groups and / or hosts</span>
<span class="pl-s"></span>
<span class="pl-s">    """</span>

    <span class="pl-k">def</span> <span class="pl-en">__init__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">inventory</span>):
        <span class="pl-s1">self</span>.<span class="pl-s1">inventory</span> <span class="pl-c1">=</span> <span class="pl-s1">inventory</span>
        <span class="pl-s1">self</span>.<span class="pl-s1">inventory_basedir</span> <span class="pl-c1">=</span> <span class="pl-s1">inventory</span>.<span class="pl-en">basedir</span>()

    <span class="pl-k">def</span> <span class="pl-en">append_test</span>(<span class="pl-s1">self</span>, <span class="pl-s1">groupvars</span>):
        <span class="pl-s1">results</span> <span class="pl-c1">=</span> {}
        <span class="pl-k">if</span> <span class="pl-s">'test'</span> <span class="pl-c1">in</span> <span class="pl-s1">groupvars</span>:
            <span class="pl-s1">results</span>.<span class="pl-en">update</span>({<span class="pl-s">'test_plugin'</span>: <span class="pl-s">'yes'</span>})

        <span class="pl-k">return</span> <span class="pl-s1">results</span>

    <span class="pl-k">def</span> <span class="pl-en">get_host_vars</span>(<span class="pl-s1">self</span>, <span class="pl-s1">host</span>, <span class="pl-s1">vault_password</span><span class="pl-c1">=</span><span class="pl-c1">None</span>):
        <span class="pl-s">""" Get host specific variables. """</span>
        <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-en">append_test</span>(<span class="pl-s1">host</span>.<span class="pl-en">get_group_vars</span>())</pre></div>
<p dir="auto">And update <code class="notranslate">ansible.cfg</code> with</p>
<div class="highlight highlight-source-ini notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="[defaults]
...
vars_plugins = vars_plugins"><pre class="notranslate"><span class="pl-en">[defaults]</span>
...
<span class="pl-k">vars_plugins</span> = vars_plugins</pre></div>
<p dir="auto">Then I test with the following command:</p>

<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="ansible -m debug -a &quot;var=hostvars[inventory_hostname]&quot; all"><pre class="notranslate">ansible -m debug -a <span class="pl-s"><span class="pl-pds">"</span>var=hostvars[inventory_hostname]<span class="pl-pds">"</span></span> all</pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">I expect the vars_plugin to add what I wanted like so:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ ansible -m debug -a &quot;var=hostvars[inventory_hostname]&quot; all -vvvv
Using /vagrant/test/ansible.cfg as config file
Loaded callback minimal of type stdout, v2.0
test1.vagrant | SUCCESS =&gt; {
    &quot;hostvars[inventory_hostname]&quot;: {
        &quot;ansible_check_mode&quot;: false, 
        &quot;ansible_version&quot;: {
            &quot;full&quot;: &quot;2.1.0.0&quot;, 
            &quot;major&quot;: 2, 
            &quot;minor&quot;: 1, 
            &quot;revision&quot;: 0, 
            &quot;string&quot;: &quot;2.1.0.0&quot;
        }, 
        &quot;group_names&quot;: [
            &quot;ungrouped&quot;
        ], 
        &quot;groups&quot;: {
            &quot;all&quot;: [
                &quot;test1.vagrant&quot;
            ], 
            &quot;ungrouped&quot;: [
                &quot;test1.vagrant&quot;
            ]
        }, 
        &quot;inventory_dir&quot;: &quot;/vagrant/test/inventory/vagrant&quot;, 
        &quot;inventory_file&quot;: null, 
        &quot;inventory_hostname&quot;: &quot;test1.vagrant&quot;, 
        &quot;inventory_hostname_short&quot;: &quot;test1&quot;, 
        &quot;omit&quot;: &quot;__omit_place_holder__c1b35db14631b948fefe0c3827f517cea304164c&quot;, 
        &quot;playbook_dir&quot;: &quot;.&quot;, 
        &quot;test&quot;: [
            &quot;a&quot;
        ], 
        &quot;test_plugin&quot;: &quot;yes&quot;
    }
}"><pre class="notranslate">$ ansible -m debug -a <span class="pl-s"><span class="pl-pds">"</span>var=hostvars[inventory_hostname]<span class="pl-pds">"</span></span> all -vvvv
Using /vagrant/test/ansible.cfg as config file
Loaded callback minimal of <span class="pl-c1">type</span> stdout, v2.0
test1.vagrant <span class="pl-k">|</span> SUCCESS =<span class="pl-k">&gt;</span> {
    <span class="pl-s"><span class="pl-pds">"</span>hostvars[inventory_hostname]<span class="pl-pds">"</span></span>: {
        <span class="pl-s"><span class="pl-pds">"</span>ansible_check_mode<span class="pl-pds">"</span></span>: false, 
        <span class="pl-s"><span class="pl-pds">"</span>ansible_version<span class="pl-pds">"</span></span>: {
            <span class="pl-s"><span class="pl-pds">"</span>full<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>2.1.0.0<span class="pl-pds">"</span></span>, 
            <span class="pl-s"><span class="pl-pds">"</span>major<span class="pl-pds">"</span></span>: 2, 
            <span class="pl-s"><span class="pl-pds">"</span>minor<span class="pl-pds">"</span></span>: 1, 
            <span class="pl-s"><span class="pl-pds">"</span>revision<span class="pl-pds">"</span></span>: 0, 
            <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>2.1.0.0<span class="pl-pds">"</span></span>
        }, 
        <span class="pl-s"><span class="pl-pds">"</span>group_names<span class="pl-pds">"</span></span>: [
            <span class="pl-s"><span class="pl-pds">"</span>ungrouped<span class="pl-pds">"</span></span>
        ], 
        <span class="pl-s"><span class="pl-pds">"</span>groups<span class="pl-pds">"</span></span>: {
            <span class="pl-s"><span class="pl-pds">"</span>all<span class="pl-pds">"</span></span>: [
                <span class="pl-s"><span class="pl-pds">"</span>test1.vagrant<span class="pl-pds">"</span></span>
            ], 
            <span class="pl-s"><span class="pl-pds">"</span>ungrouped<span class="pl-pds">"</span></span>: [
                <span class="pl-s"><span class="pl-pds">"</span>test1.vagrant<span class="pl-pds">"</span></span>
            ]
        }, 
        <span class="pl-s"><span class="pl-pds">"</span>inventory_dir<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>/vagrant/test/inventory/vagrant<span class="pl-pds">"</span></span>, 
        <span class="pl-s"><span class="pl-pds">"</span>inventory_file<span class="pl-pds">"</span></span>: null, 
        <span class="pl-s"><span class="pl-pds">"</span>inventory_hostname<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>test1.vagrant<span class="pl-pds">"</span></span>, 
        <span class="pl-s"><span class="pl-pds">"</span>inventory_hostname_short<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>test1<span class="pl-pds">"</span></span>, 
        <span class="pl-s"><span class="pl-pds">"</span>omit<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>__omit_place_holder__c1b35db14631b948fefe0c3827f517cea304164c<span class="pl-pds">"</span></span>, 
        <span class="pl-s"><span class="pl-pds">"</span>playbook_dir<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>.<span class="pl-pds">"</span></span>, 
        <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>: [
            <span class="pl-s"><span class="pl-pds">"</span>a<span class="pl-pds">"</span></span>
        ], 
        <span class="pl-s"><span class="pl-pds">"</span>test_plugin<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>yes<span class="pl-pds">"</span></span>
    }
}</pre></div>
<p dir="auto">I downgraded from 2.2 step by step down to 2.1 and found all versions after <strong>2.1.0.0</strong> have this issue.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ ansible -m debug -a &quot;var=hostvars[inventory_hostname]&quot; all -vvvv
Using /vagrant/test/ansible.cfg as config file
Loading callback plugin minimal of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pyc
test1.vagrant | SUCCESS =&gt; {
    &quot;hostvars[inventory_hostname]&quot;: {
        &quot;ansible_check_mode&quot;: false, 
        &quot;ansible_version&quot;: {
            &quot;full&quot;: &quot;2.2.0.0&quot;, 
            &quot;major&quot;: 2, 
            &quot;minor&quot;: 2, 
            &quot;revision&quot;: 0, 
            &quot;string&quot;: &quot;2.2.0.0&quot;
        },  
        &quot;group_names&quot;: [
            &quot;ungrouped&quot;
        ], 
        &quot;groups&quot;: {
            &quot;all&quot;: [
                &quot;test1.vagrant&quot;
            ], 
            &quot;ungrouped&quot;: [
                &quot;test1.vagrant&quot;
            ]
        }, 
        &quot;inventory_dir&quot;: &quot;/vagrant/test/inventory/vagrant&quot;, 
        &quot;inventory_file&quot;: null, 
        &quot;inventory_hostname&quot;: &quot;test1.vagrant&quot;, 
        &quot;inventory_hostname_short&quot;: &quot;test1&quot;, 
        &quot;omit&quot;: &quot;__omit_place_holder__857b85a3093a239f7cbe078c9c82877e33561bcd&quot;, 
        &quot;playbook_dir&quot;: &quot;.&quot;, 
        &quot;test&quot;: [
            &quot;a&quot;
        ]
    }
}"><pre class="notranslate">$ ansible -m debug -a <span class="pl-s"><span class="pl-pds">"</span>var=hostvars[inventory_hostname]<span class="pl-pds">"</span></span> all -vvvv
Using /vagrant/test/ansible.cfg as config file
Loading callback plugin minimal of <span class="pl-c1">type</span> stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pyc
test1.vagrant <span class="pl-k">|</span> SUCCESS =<span class="pl-k">&gt;</span> {
    <span class="pl-s"><span class="pl-pds">"</span>hostvars[inventory_hostname]<span class="pl-pds">"</span></span>: {
        <span class="pl-s"><span class="pl-pds">"</span>ansible_check_mode<span class="pl-pds">"</span></span>: false, 
        <span class="pl-s"><span class="pl-pds">"</span>ansible_version<span class="pl-pds">"</span></span>: {
            <span class="pl-s"><span class="pl-pds">"</span>full<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>2.2.0.0<span class="pl-pds">"</span></span>, 
            <span class="pl-s"><span class="pl-pds">"</span>major<span class="pl-pds">"</span></span>: 2, 
            <span class="pl-s"><span class="pl-pds">"</span>minor<span class="pl-pds">"</span></span>: 2, 
            <span class="pl-s"><span class="pl-pds">"</span>revision<span class="pl-pds">"</span></span>: 0, 
            <span class="pl-s"><span class="pl-pds">"</span>string<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>2.2.0.0<span class="pl-pds">"</span></span>
        },  
        <span class="pl-s"><span class="pl-pds">"</span>group_names<span class="pl-pds">"</span></span>: [
            <span class="pl-s"><span class="pl-pds">"</span>ungrouped<span class="pl-pds">"</span></span>
        ], 
        <span class="pl-s"><span class="pl-pds">"</span>groups<span class="pl-pds">"</span></span>: {
            <span class="pl-s"><span class="pl-pds">"</span>all<span class="pl-pds">"</span></span>: [
                <span class="pl-s"><span class="pl-pds">"</span>test1.vagrant<span class="pl-pds">"</span></span>
            ], 
            <span class="pl-s"><span class="pl-pds">"</span>ungrouped<span class="pl-pds">"</span></span>: [
                <span class="pl-s"><span class="pl-pds">"</span>test1.vagrant<span class="pl-pds">"</span></span>
            ]
        }, 
        <span class="pl-s"><span class="pl-pds">"</span>inventory_dir<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>/vagrant/test/inventory/vagrant<span class="pl-pds">"</span></span>, 
        <span class="pl-s"><span class="pl-pds">"</span>inventory_file<span class="pl-pds">"</span></span>: null, 
        <span class="pl-s"><span class="pl-pds">"</span>inventory_hostname<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>test1.vagrant<span class="pl-pds">"</span></span>, 
        <span class="pl-s"><span class="pl-pds">"</span>inventory_hostname_short<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>test1<span class="pl-pds">"</span></span>, 
        <span class="pl-s"><span class="pl-pds">"</span>omit<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>__omit_place_holder__857b85a3093a239f7cbe078c9c82877e33561bcd<span class="pl-pds">"</span></span>, 
        <span class="pl-s"><span class="pl-pds">"</span>playbook_dir<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>.<span class="pl-pds">"</span></span>, 
        <span class="pl-s"><span class="pl-pds">"</span>test<span class="pl-pds">"</span></span>: [
            <span class="pl-s"><span class="pl-pds">"</span>a<span class="pl-pds">"</span></span>
        ]
    }
}</pre></div>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Feature Idea</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.5.0
  config file = /home/conductor/playbooks/ansible.cfg
  configured module search path = ['/home/conductor/playbooks/plugins/modules']
  ansible python module location = /home/conductor/env/lib/python3.5/site-packages/ansible
  executable location = /home/conductor/env/bin/ansible
  python version = 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609]"><pre class="notranslate"><code class="notranslate">ansible 2.5.0
  config file = /home/conductor/playbooks/ansible.cfg
  configured module search path = ['/home/conductor/playbooks/plugins/modules']
  ansible python module location = /home/conductor/env/lib/python3.5/site-packages/ansible
  executable location = /home/conductor/env/bin/ansible
  python version = 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="CACHE_PLUGIN(/home/conductor/playbooks/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/conductor/playbooks/ansible.cfg) = ~/.ansible/facts
CACHE_PLUGIN_TIMEOUT(/home/conductor/playbooks/ansible.cfg) = 86400
DEFAULT_DEBUG(/home/conductor/playbooks/ansible.cfg) = False
DEFAULT_GATHERING(/home/conductor/playbooks/ansible.cfg) = smart
DEFAULT_JINJA2_EXTENSIONS(/home/conductor/playbooks/ansible.cfg) = jinja2.ext.do,jinja2.ext.i18n
INJECT_FACTS_AS_VARS(/home/conductor/playbooks/ansible.cfg) = False
MERGE_MULTIPLE_CLI_TAGS(/home/conductor/playbooks/ansible.cfg) = True
RETRY_FILES_ENABLED(/home/conductor/playbooks/ansible.cfg) = False"><pre class="notranslate"><code class="notranslate">CACHE_PLUGIN(/home/conductor/playbooks/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/conductor/playbooks/ansible.cfg) = ~/.ansible/facts
CACHE_PLUGIN_TIMEOUT(/home/conductor/playbooks/ansible.cfg) = 86400
DEFAULT_DEBUG(/home/conductor/playbooks/ansible.cfg) = False
DEFAULT_GATHERING(/home/conductor/playbooks/ansible.cfg) = smart
DEFAULT_JINJA2_EXTENSIONS(/home/conductor/playbooks/ansible.cfg) = jinja2.ext.do,jinja2.ext.i18n
INJECT_FACTS_AS_VARS(/home/conductor/playbooks/ansible.cfg) = False
MERGE_MULTIPLE_CLI_TAGS(/home/conductor/playbooks/ansible.cfg) = True
RETRY_FILES_ENABLED(/home/conductor/playbooks/ansible.cfg) = False
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">N/A</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">I'm trying to use the modern role include syntax to mix tasks and roles import in a playbook but switching to "classic manner" to the "import_include" syntax cause undefined variables issues.</p>
<p dir="auto">When using the classic syntax, the role's defaults are visible inside the playbook file and other roles. When using import_roles, the role's defaults are visible only inside the role that declare them.</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:
    - import_role: { name: myrole }
    - debug:
        msg: &quot;myrole default: {{ myrole_default }}&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">import_role</span>: <span class="pl-s">{ name: myrole }</span>
    - <span class="pl-ent">debug</span>:
        <span class="pl-ent">msg</span>: <span class="pl-s"><span class="pl-pds">"</span>myrole default: {{ myrole_default }}<span class="pl-pds">"</span></span></pre></div>
<p dir="auto">file: roles/myrole/defaults/main.yaml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="myrole_default: &quot;hello&quot;"><pre class="notranslate"><span class="pl-ent">myrole_default</span>: <span class="pl-s"><span class="pl-pds">"</span>hello<span class="pl-pds">"</span></span></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [debug] *****************************************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;myrole default: hello&quot;
}"><pre class="notranslate"><code class="notranslate">TASK [debug] *****************************************************************************************
ok: [localhost] =&gt; {
    "msg": "myrole default: hello"
}
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [debug] *****************************************************************************************
task path: /Users/jddupas/Projects/python/playbooks/playbook.yaml:4
fatal: [localhost]: FAILED! =&gt; {
    &quot;msg&quot;: &quot;The task includes an option with an undefined variable. The error was: 'myrole_default' is undefined\n\nThe error appears to have been in '/Users/jddupas/Projects/python/playbooks/playbook.yaml': line 4, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n    - import_role: { name: myrole }\n    - debug:\n      ^ here\n&quot;
}"><pre class="notranslate"><code class="notranslate">TASK [debug] *****************************************************************************************
task path: /Users/jddupas/Projects/python/playbooks/playbook.yaml:4
fatal: [localhost]: FAILED! =&gt; {
    "msg": "The task includes an option with an undefined variable. The error was: 'myrole_default' is undefined\n\nThe error appears to have been in '/Users/jddupas/Projects/python/playbooks/playbook.yaml': line 4, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n    - import_role: { name: myrole }\n    - debug:\n      ^ here\n"
}
</code></pre></div>
<p dir="auto">Note:  When using the classic syntax, it works fine (but I can't mix tasks and roles as I need):</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- hosts: localhost
  roles:
    - myrole
  tasks:
    - debug:
        msg: &quot;myrole default: {{ myrole_default }}&quot;"><pre class="notranslate">- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
  <span class="pl-ent">roles</span>:
    - <span class="pl-s">myrole</span>
  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">debug</span>:
        <span class="pl-ent">msg</span>: <span class="pl-s"><span class="pl-pds">"</span>myrole default: {{ myrole_default }}<span class="pl-pds">"</span></span></pre></div>