# AttributeError: 'module' object has no attribute 'ModuleReplacer' when trying to create a custom mod

**URL:** <https://forum.ansible.com/t/attributeerror-module-object-has-no-attribute-modulereplacer-when-trying-to-create-a-custom-mod/13935>\
**Category:** Ansible Developer\
**Created:** [November 19, 2013, 1:42pm UTC](https://forum.ansible.com/t/attributeerror-module-object-has-no-attribute-modulereplacer-when-trying-to-create-a-custom-mod/13935 "2013-11-19T13:42:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Vonk](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@Lars\_Vonk](https://forum.ansible.com/u/Lars_Vonk)\
**Post date:** [November 19, 2013, 1:42pm UTC](https://forum.ansible.com/t/attributeerror-module-object-has-no-attribute-modulereplacer-when-trying-to-create-a-custom-mod/13935/1 "2013-11-19T13:42:58Z")

</div>

Hi,

I am trying to create a custom module based on pyrax (rackspace) to create reverse dns entries. I followed the hacking guide but I am stuck testing the new module because of an AttributeError: ‘module’ object has no attribute ‘ModuleReplacer’ error.

My set up is as follows:

Mac OSX, installed python with brew and using pip for the dependencies. Local python is at /usr/local/bin/python. Then I following the hacking guide at [http://www.ansibleworks.com/docs/developing\_modules.html](http://www.ansibleworks.com/docs/developing_modules.html)and checked out ansible, ran ./hacking/env-setup and than:

./hacking/test-module -m ../servers/modules/rax\_dns

Output:

Traceback (most recent call last):

File “./hacking/test-module”, line 163, in

main()

File “./hacking/test-module”, line 147, in main

(modfile, module\_style) = boilerplate\_module(options.module\_path, options.module\_args)

File “./hacking/test-module”, line 84, in boilerplate\_module

replacer = module\_common.ModuleReplacer()

The rax\_dns:

#!/usr/bin/python #changing this to /usr/local/bin/python has no effect.

import pyrax

def main():

module = AnsibleModule(

argument\_spec = dict(

credentials = dict(required=True),

hostname = dict(required=True)

)

)

pyrax.set\_setting(“identity\_type”, “rackspace”)

pyrax.set\_credential\_file(credentials)

# include magic from lib/ansible/module\_common.py

#\<\<INCLUDE\_ANSIBLE\_MODULE\_COMMON\>\>

main()

What am I missing?

Lars

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 20, 2013, 3:48am UTC](https://forum.ansible.com/t/attributeerror-module-object-has-no-attribute-modulereplacer-when-trying-to-create-a-custom-mod/13935/2 "2013-11-20T03:48:25Z")

</div>

sounds like you should source ./hacking/env-setup

as you are developing against a new ansible with an old ansible installed.

just a guess!

---

<div class="post-metadata">

**Author:** ![Lars\_Vonk](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@Lars\_Vonk](https://forum.ansible.com/u/Lars_Vonk)\
**Post date:** [November 20, 2013, 11:08am UTC](https://forum.ansible.com/t/attributeerror-module-object-has-no-attribute-modulereplacer-when-trying-to-create-a-custom-mod/13935/3 "2013-11-20T11:08:11Z")

</div>

Hi,

I didn’t mention that in the first post, but I already ran that and it doesn’t help. The module works when ran from my project and extending the module-path with the --module-path argument.

Here is the full output:

---

<div class="post-metadata">

**Author:** ![Nick\_Groenen](https://avatars.discourse-cdn.com/v4/letter/n/c77e96/32.png) [@Nick\_Groenen](https://forum.ansible.com/u/Nick_Groenen)\
**Post date:** [November 20, 2013, 1:11pm UTC](https://forum.ansible.com/t/attributeerror-module-object-has-no-attribute-modulereplacer-when-trying-to-create-a-custom-mod/13935/4 "2013-11-20T13:11:05Z")

</div>

env-setup needs to be sourced (source hacking/env-setup) rather than  
just executed, otherwise the exports that are done inside of it will  
end up having no effect 🙂

---

<div class="post-metadata">

**Author:** ![Lars\_Vonk](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@Lars\_Vonk](https://forum.ansible.com/u/Lars_Vonk)\
**Post date:** [November 20, 2013, 2:05pm UTC](https://forum.ansible.com/t/attributeerror-module-object-has-no-attribute-modulereplacer-when-trying-to-create-a-custom-mod/13935/5 "2013-11-20T14:05:10Z")

</div>

Jup… Just like the readme says I should… doh.

Thanks!

Lars
