# from ansible.utils Cannot import makedirs\_safe

**URL:** <https://forum.ansible.com/t/from-ansible-utils-cannot-import-makedirs-safe/18385>\
**Category:** Ansible Project\
**Created:** [June 3, 2015, 1:25am UTC](https://forum.ansible.com/t/from-ansible-utils-cannot-import-makedirs-safe/18385 "2015-06-03T01:25:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Legleux](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@Michael\_Legleux](https://forum.ansible.com/u/Michael_Legleux)\
**Post date:** [June 3, 2015, 1:25am UTC](https://forum.ansible.com/t/from-ansible-utils-cannot-import-makedirs-safe/18385/1 "2015-06-03T01:25:05Z")

</div>

Since my host\_var and group\_var s are not getting used since I updated ansible to the latest git checkout last night, I decided to put the variables directly in my inventory file.  
Now it seems like they might be getting read, but now I get this error:  
ImportError: cannot import name makedirs\_safe

This was just trying ansible win7 -m win\_ping

win7 | FAILED! =\> {‘failed’: True, ‘exception’: 'Traceback (most recent call last):\n File "/home/ansible/ansible/lib/ansible/executor/proc

ess/worker.py", line 118, in run\n executor\_result = TaskExecutor(host, task, job\_vars, new\_connection\_info, self.\_new\_stdin, self.\_loade  
r, shared\_loader\_obj).run()\n File “/home/ansible/ansible/lib/ansible/executor/task\_executor.py”, line 107, in run\n res = self.\_execute  
()\n File “/home/ansible/ansible/lib/ansible/executor/task\_executor.py”, line 211, in \_execute\n self.\_connection = self.\_get\_connection  
(variables)\n File “/home/ansible/ansible/lib/ansible/executor/task\_executor.py”, line 395, in \_get\_connection\n connection = connection  
\_loader.get(conn\_type, self.\_connection\_info, self.\_new\_stdin)\n File “/home/ansible/ansible/lib/ansible/plugins/ **init**.py”, line 271, in  
get\n self.\_module\_cache[path] = imp.load\_source('.'.join([self.package, name]), path)\n File “/home/ansible/ansible/lib/ansible/plug  
ins/connections/winrm.py”, line 47, in \n from ansible.utils import makedirs\_safe\nImportError: cannot import name makedirs\_safe  
n’, ‘stdout’: ‘’}

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 3, 2015, 3:38am UTC](https://forum.ansible.com/t/from-ansible-utils-cannot-import-makedirs-safe/18385/2 "2015-06-03T03:38:34Z")

</div>

should be fixed now, pull and try again (i was missing path in import  
path for make path utility)

---

<div class="post-metadata">

**Author:** ![Michael\_Legleux](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@Michael\_Legleux](https://forum.ansible.com/u/Michael_Legleux)\
**Post date:** [June 3, 2015, 6:13pm UTC](https://forum.ansible.com/t/from-ansible-utils-cannot-import-makedirs-safe/18385/3 "2015-06-03T18:13:39Z")

</div>

Well I don’t see the import error anymore but most of the error is the same:  
Now I get this:

win7 | FAILED! =\> {‘failed’: True, ‘exception’: ‘Traceback (most recent call last):\n File “/home/ansible/ansible/lib/ansible/executor/proc  
ess/worker.py”, line 118, in run\n executor\_result = TaskExecutor(host, task, job\_vars, new\_connection\_info, self.\_new\_stdin, self.\_loade  
r, shared\_loader\_obj).run()\n File “/home/ansible/ansible/lib/ansible/executor/task\_executor.py”, line 107, in run\n res = self.\_execute  
()\n File “/home/ansible/ansible/lib/ansible/executor/task\_executor.py”, line 215, in \_execute\n self.\_handler = self.\_get\_action\_handle  
r(connection=self.\_connection, templar=templar)\n File “/home/ansible/ansible/lib/ansible/executor/task\_executor.py”, line 422, in \_get\_act  
ion\_handler\n shared\_loader\_obj=self._shared\_loader\_obj,\n File “/home/ansible/ansible/lib/ansible/plugins/ **init**.py”, line 276, in ge  
t\n obj = getattr(self.module\_cache[path], self.class\_name)(\*args, \*\*kwargs)\n File "/home/ansible/ansible/lib/ansible/plugins/action/  
 init_.py", line 64, in **init** \n self.\_shell = shell\_loader.get(shell\_type)\n File "/home/ansible/ansible/lib/ansible/plugins/\__init_  
_.py", line 266, in get\n path = self.find\_plugin(name)\n File “/home/ansible/ansible/lib/ansible/plugins/ **init**.py”, line 246, in fin  
d\_plugin\n if not name.startswith('_'):\nAttributeError: 'ShellModule' object has no attribute 'startswith'\n’, ‘stdout’: ‘’}

win8 | FAILED! =\> {‘msg’: u’ERROR! 500 WinRMTransport. [Errno -3] Temporary failure in name resolution’, ‘failed’: True}

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 3, 2015, 6:46pm UTC](https://forum.ansible.com/t/from-ansible-utils-cannot-import-makedirs-safe/18385/4 "2015-06-03T18:46:11Z")

</div>

that is probably different but unrelated issue, are you relying on  
ansible\_ssh\_host to set the correct address? if so that is a currently  
open issue.

---

<div class="post-metadata">

**Author:** ![Michael\_Legleux](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@Michael\_Legleux](https://forum.ansible.com/u/Michael_Legleux)\
**Post date:** [June 3, 2015, 9:49pm UTC](https://forum.ansible.com/t/from-ansible-utils-cannot-import-makedirs-safe/18385/5 "2015-06-03T21:49:49Z")

</div>

I currently am relying on ansible\_ssh\_host.  
I am assuming once our client machines have DNS entries, the ansible server will not need ansible\_ssh\_host defined correct?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 3, 2015, 10:05pm UTC](https://forum.ansible.com/t/from-ansible-utils-cannot-import-makedirs-safe/18385/6 "2015-06-03T22:05:39Z")

</div>

as long as the inventory\_hostname is resolvable, there is not need for  
ansible\_ssh\_host

---

<div class="post-metadata">

**Author:** ![Daniel\_Pool](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@Daniel\_Pool](https://forum.ansible.com/u/Daniel_Pool)\
**Post date:** [June 10, 2015, 9:14pm UTC](https://forum.ansible.com/t/from-ansible-utils-cannot-import-makedirs-safe/18385/7 "2015-06-10T21:14:57Z")

</div>

Hi,

I’m having a similar problem since pulling the latest (d681113) revision in git. I’m not relying on ansible\_ssh\_host though, my trace output is identical to Michael’s win7 host.

Attaching the epdb debugger I outputted the value of name, which just prior to the error had the value:

\<ansible.plugins.shell.powershell.ShellModule object at 0x1ab2dd0\>

which looks to me to be an object’s memory reference rather than a string (I’m no python developer though, so I’m taking a punt based on other language experience).

looking at the source of ansible/lib/ansible/plugins/action/ **init**.py, it looks like the powershell ShellModule is being pulled off the connection.\_shell property. I added (a probably incorrect test) to see if shell\_type was a string, in which case I called the shell\_loader, otherwise I directly assigned the shell\_type to self.\_shell.

if isinstance(shell\_type, basestring):  
self.\_shell = shell\_loader.get(shell\_type)  
else:  
self.\_shell = shell\_type

Suspect that this’ll break a bunch of other stuff, but it appears to be working for the moment. I figured that I’d push this out here as Brian looks to be far better qualified to say either way.  
~Dan

---

<div class="post-metadata">

**Author:** ![Daniel\_Pool](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@Daniel\_Pool](https://forum.ansible.com/u/Daniel_Pool)\
**Post date:** [June 11, 2015, 1:40am UTC](https://forum.ansible.com/t/from-ansible-utils-cannot-import-makedirs-safe/18385/8 "2015-06-11T01:40:56Z")

</div>

OK, perhaps not the solution - getting errors with module parameters.
