Apologies if this topic has been hashed to death - but I wanted to follow 
up to see if there is a simple/clever way to solve this problem. I too am 
writing custom modules for Xen and there's a lot of boilerplate code common 
to many such modules that would be better off in a common shared python 
file rather than exist in each module file. It would definitely be nice if 
this could be done declaratively within each module file rather than 
hacking module_utils or some such "unsanctioned" mechanism.



On Friday, February 21, 2014 4:38:31 PM UTC-6, Raphael Randschau wrote:
>
> Hey there,
>
> while working on [ansible-rails][1] I came across a problem I have not yet 
> been able to solve by just reading and interpreting the ansible source code:
>
> how can I share common dependencies between multiple, custom commands? 
> E.g. given the following role directory structure:
>
> /example
> /example/library
> /example/library/command_a
> /example/library/command_b
> /example/library/shared_utility.py
> /example/library/__init__.py
>
> shared_utility.py contains classes used in both command_a AND command_b. 
>
> The way I understand ansible right now is that when command_a is used 
> inside a playbook/ role it's source is expanded and copied to the server 
> (sie ModuleReplacer inside the ansible source).
> However, due to this processing, I can't just import shared_utility, 
> because it's not copied to the remote server.
>
> My question now is this: how do I import shared code into ansible 
> commands? And equally important: how do I properly test these custom 
> commands without much hackery (I'm talking about good old unit tests in 
> this case!)
>
> Please advice - is this left out on purpose or just very badly documented 
> & hidden away?
>
> Thanks,
> Raphael
>
> [1]:https://github.com/nicolai86/ansible-rails
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/df136584-a555-4039-b433-4d0f9e7ce391%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to