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

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.htmland 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

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

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

just a guess!

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:

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 :slight_smile:

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

Thanks!

Lars