Re: [ansible-project] Re: include custom python library from custom module

2016-03-23 Thread Toshio Kuratomi
On Mar 23, 2016 6:48 AM, "夏恺(Xia Kai)"  wrote:
>
> I'm working on a similar problem, and I have to write an action plugin
for it. As far as I know, and as much as I understand, there is no out of
the box way to do this.
>
You can copy the file into the module_utils directory in your ansible
install.  Then you should be able to use it similar to how most ansible
modules use the basic.py module listed there.  Note that we're making some
changes to how this works for 2.1 and (maybe for 2.1 but more likely for
2.2 due to the amount of time left before we want to release 2.1) will be
looking at enabling a user directory where these sorts of small, custom
libraries can live.  (The new module loader code is talked about here:
https://groups.google.com/forum/m/#!msg/ansible-project/0bwHEFfKOro/meU337AxCQAJ
I don't highlight user directories for custom code in the posts about it
because the timing means that additional feature likely won't make it into
2.1)

-Toshio
>
> On Tuesday, March 22, 2016 at 2:41:07 AM UTC+8, Alexey Wasilyev wrote:
>>
>> Hello!
>>
>> I am writing a set of custom ansible modules, that uses some shared code.
>> And cant find a right way how this can be organised. Where I should put
my custom python library under current catalog so it can be imported by my
modules?
>>
>> I don't want to makes "official" library, available via pip, and I don't
want to copy it manually out of current playbook tree.
>>
>>
>> Alexey
>
> --
> 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/bced9465-3175-4743-ade6-a1f071a6c5c4%40googlegroups.com
.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
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/CAG9juEryXUknW-46v%2BCqsVbnMGLaC21JuG-8g9h%3D2EvjoP0uRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: include custom python library from custom module

2016-03-23 Thread Xia Kai
I'm working on a similar problem, and I have to write an action plugin for 
it. As far as I know, and as much as I understand, there is no out of the 
box way to do this.

On Tuesday, March 22, 2016 at 2:41:07 AM UTC+8, Alexey Wasilyev wrote:
>
> Hello!
>
> I am writing a set of custom ansible modules, that uses some shared code.
> And cant find a right way how this can be organised. Where I should put my 
> custom python library under current catalog so it can be imported by my 
> modules?
>
> I don't want to makes "official" library, available via pip, and I don't 
> want to copy it manually out of current playbook tree.
>
>
> Alexey
>

-- 
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/bced9465-3175-4743-ade6-a1f071a6c5c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: include custom python library from custom module

2016-03-23 Thread Mike Biancaniello
duh, right. It works for connection: local, but not for remote targets.

Maybe have a task that copies it to a tmp dir on the target and then append 
that to sys.path in your module?

On Wednesday, March 23, 2016 at 7:43:19 AM UTC-4, Uditha Desilva wrote:
>
> Does that really work to copy over the dependent libraries to the target 
> systems?
>
> On Tuesday, 22 March 2016 17:13:38 UTC, Mike Biancaniello wrote:
>>
>> You can put them in the same or sub dir as your modules. Or, you can put 
>> them anywhere, just append the path in the module. However, if you want 
>> multiple modules in multiple roles to share the same libs, then things get 
>> tricky. I've done that by appending '../../pylibs/' to my sys.path to get 
>> things up and running, but eventually just installed the libs globally on 
>> the system and did away with that ugliness. Of course, you could always 
>> just run ansible inside of a docker or python-virtualenv and then install 
>> the libs local to that environment.
>>
>

-- 
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/fcf7dc96-4f16-411e-bbcf-d18d15486c69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: include custom python library from custom module

2016-03-23 Thread Uditha Desilva
Does that really work to copy over the dependent libraries to the target 
systems?

On Tuesday, 22 March 2016 17:13:38 UTC, Mike Biancaniello wrote:
>
> You can put them in the same or sub dir as your modules. Or, you can put 
> them anywhere, just append the path in the module. However, if you want 
> multiple modules in multiple roles to share the same libs, then things get 
> tricky. I've done that by appending '../../pylibs/' to my sys.path to get 
> things up and running, but eventually just installed the libs globally on 
> the system and did away with that ugliness. Of course, you could always 
> just run ansible inside of a docker or python-virtualenv and then install 
> the libs local to that environment.
>

-- 
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/d2c77d03-1f00-45c2-957b-41313386e216%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: include custom python library from custom module

2016-03-22 Thread Mike Biancaniello
You can put them in the same or sub dir as your modules. Or, you can put 
them anywhere, just append the path in the module. However, if you want 
multiple modules in multiple roles to share the same libs, then things get 
tricky. I've done that by appending '../../pylibs/' to my sys.path to get 
things up and running, but eventually just installed the libs globally on 
the system and did away with that ugliness. Of course, you could always 
just run ansible inside of a docker or python-virtualenv and then install 
the libs local to that environment.

-- 
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/4bfa2fe5-006f-43f1-be30-3a0ddf4403bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: include custom python library from custom module

2016-03-22 Thread Uditha Desilva
Given my understanding of the way Ansible bundles up modules, I am not sure 
that will work. You may need to install your custom python libraries on 
each of your target systems.

On Monday, 21 March 2016 18:41:07 UTC, Alexey Wasilyev wrote:
>
> Hello!
>
> I am writing a set of custom ansible modules, that uses some shared code.
> And cant find a right way how this can be organised. Where I should put my 
> custom python library under current catalog so it can be imported by my 
> modules?
>
> I don't want to makes "official" library, available via pip, and I don't 
> want to copy it manually out of current playbook tree.
>
>
> Alexey
>

-- 
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/5007aa5a-5d53-4d05-8fd2-ae0bad6d7f0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.