<p dir="auto">In the process of learning how to use ansible with my linode I had pip installed all the necessary libraries.  Then I had cloned the ansible repository to have access to the inventory scripts in my local documents folder.  When I cloned the main repo I named it <code class="notranslate">ansible-src/</code> just so I'd remember that it was a clone from a read only repo.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python ansible-src/plugins/inventory/linode.py"><pre class="notranslate"><code class="notranslate">python ansible-src/plugins/inventory/linode.py
</code></pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    Traceback (most recent call last):
      File &quot;plugins/inventory/linode.py&quot;, line 87, in &lt;module&gt;
        from chube import *
      File &quot;/usr/local/lib/python2.7/site-packages/chube/__init__.py&quot;, line 4, in &lt;module&gt;
        from .api import api_handler as chube_api_handler
      File &quot;/usr/local/lib/python2.7/site-packages/chube/api.py&quot;, line 1, in &lt;module&gt;
        from linode import api as linode_api
      File &quot;/Users/morgan.craft/Documents/projects/ansible-src/plugins/inventory/linode.py&quot;, line 89, in &lt;module&gt;
        load_chube_config()
    NameError: name 'load_chube_config' is not defined"><pre class="notranslate">    Traceback (most recent call last):
      File <span class="pl-s"><span class="pl-pds">"</span>plugins/inventory/linode.py<span class="pl-pds">"</span></span>, line 87, <span class="pl-k">in</span> <span class="pl-k">&lt;</span>module<span class="pl-k">&gt;</span>
        from chube import <span class="pl-k">*</span>
      File <span class="pl-s"><span class="pl-pds">"</span>/usr/local/lib/python2.7/site-packages/chube/__init__.py<span class="pl-pds">"</span></span>, line 4, <span class="pl-k">in</span> <span class="pl-k">&lt;</span>module<span class="pl-k">&gt;</span>
        from .api import api_handler as chube_api_handler
      File <span class="pl-s"><span class="pl-pds">"</span>/usr/local/lib/python2.7/site-packages/chube/api.py<span class="pl-pds">"</span></span>, line 1, <span class="pl-k">in</span> <span class="pl-k">&lt;</span>module<span class="pl-k">&gt;</span>
        from linode import api as linode_api
      File <span class="pl-s"><span class="pl-pds">"</span>/Users/morgan.craft/Documents/projects/ansible-src/plugins/inventory/linode.py<span class="pl-pds">"</span></span>, line 89, <span class="pl-k">in</span> <span class="pl-k">&lt;</span>module<span class="pl-k">&gt;</span>
        <span class="pl-en">load_chube_config</span>()
    NameError: name <span class="pl-s"><span class="pl-pds">'</span>load_chube_config<span class="pl-pds">'</span></span> is not defined</pre></div>
<p dir="auto">Took me abit to sort through what was going on, at first I thought pip had exploded on me and trashed my environment. But then I found this section of code in <code class="notranslate">plugins/inventory/linode.py</code></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# chube imports 'yaml', which is also the name of an inventory plugin,
# so we remove the plugins dir from sys.path before importing it.
old_path = sys.path
sys.path = [d for d in sys.path if &quot;ansible/plugins&quot; not in d]"><pre class="notranslate"><span class="pl-c"># chube imports 'yaml', which is also the name of an inventory plugin,</span>
<span class="pl-c"># so we remove the plugins dir from sys.path before importing it.</span>
<span class="pl-s1">old_path</span> <span class="pl-c1">=</span> <span class="pl-s1">sys</span>.<span class="pl-s1">path</span>
<span class="pl-s1">sys</span>.<span class="pl-s1">path</span> <span class="pl-c1">=</span> [<span class="pl-s1">d</span> <span class="pl-k">for</span> <span class="pl-s1">d</span> <span class="pl-c1">in</span> <span class="pl-s1">sys</span>.<span class="pl-s1">path</span> <span class="pl-k">if</span> <span class="pl-s">"ansible/plugins"</span> <span class="pl-c1">not</span> <span class="pl-c1">in</span> <span class="pl-s1">d</span>]</pre></div>
<p dir="auto">Turns out <code class="notranslate">yaml</code> isn't all it blocks, but the linode.py file as well from the sys.path inclusion which causes a weird circular import.  This is because of</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="sys.path = [d for d in sys.path if &quot;ansible/plugins&quot; not in d]"><pre class="notranslate"><span class="pl-s1">sys</span>.<span class="pl-s1">path</span> <span class="pl-c1">=</span> [<span class="pl-s1">d</span> <span class="pl-k">for</span> <span class="pl-s1">d</span> <span class="pl-c1">in</span> <span class="pl-s1">sys</span>.<span class="pl-s1">path</span> <span class="pl-k">if</span> <span class="pl-s">"ansible/plugins"</span> <span class="pl-c1">not</span> <span class="pl-c1">in</span> <span class="pl-s1">d</span>]</pre></div>
<p dir="auto">I don't think we should have a hard coded file/directory path name.  Or if it is the only way then maybe we should propogate an exception if <code class="notranslate">ansible</code> is not the cloned repo name so at least devs know their file-pathing doesn't match.</p>
<p dir="auto">Happy to work on the issue and submit a pr, just want feedback on how best to approach.</p>
<p dir="auto">It would be really nice if ansible would parse the playbook YAML<br>
before requesting the sudo password.</p>
<p dir="auto">I'm just learning YAML, and rely on ansible to tell me I'm wrong. I'm<br>
frequently wrong.</p>
<p dir="auto">Our company's ansible account has a tedious and annoying sudo<br>
password. (It's not security through obscurity, it's security through<br>
"I can't even type the damn thing.")</p>
<p dir="auto">From a user perspective, this seems like an easy change to make. Any<br>
chance your could add this to ansible, even as an option in<br>
ansible.cfg or something?</p>
<p dir="auto">(filed per mpdehaan's request on mailing list)</p>