# BSD jexec module

**URL:** <https://forum.ansible.com/t/bsd-jexec-module/23040>\
**Category:** Ansible Developer\
**Created:** [November 16, 2016, 12:15pm UTC](https://forum.ansible.com/t/bsd-jexec-module/23040 "2016-11-16T12:15:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goran\_Mekic](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@Goran\_Mekic](https://forum.ansible.com/u/Goran_Mekic)\
**Post date:** [November 16, 2016, 12:15pm UTC](https://forum.ansible.com/t/bsd-jexec-module/23040/1 "2016-11-16T12:15:47Z")

</div>

Hello,

Is there a module that can use jexec on FreeBSD (e.g. "execute in jail")? In my oppinion, as jexec executes command in existing jail, something like wrapping existing modules in "jexec" when needed would be great from usability point of view. I don't know what this would mean implementation wise. So, usual questions are:

1. Is it possible?  
2. What would be considered acceptable?  
3. Is anyone working on something similar needing testing and/or contribution?

Just for reference, my use case is CBSD + jail on FreeBSD as jail house keeping, but I'd love to do provisioning of jails using Ansible, which currently means using command module and prepend every command with "jexec \<jail name or id\>", which requires variable \<jail\_name\> to be registered, first. Not the pretiest solution, and I'd love to improve it. If there are already better solutions to this use case, I would love to read about the subject.

Thank you,  
meka

---

<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:** [November 16, 2016, 9:21pm UTC](https://forum.ansible.com/t/bsd-jexec-module/23040/2 "2016-11-16T21:21:23Z")

</div>

You have already have a “jail” connection plugin, which most modules should be able to use transparently.

---

<div class="post-metadata">

**Author:** ![Goran\_Mekic](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@Goran\_Mekic](https://forum.ansible.com/u/Goran_Mekic)\
**Post date:** [November 16, 2016, 11:47pm UTC](https://forum.ansible.com/t/bsd-jexec-module/23040/3 "2016-11-16T23:47:53Z")

</div>

Works just perfect! Thank you so much! If anyone is testing, this is the command I ended up using to verify the test:

ansible all -i jail1, -c jail -m command -a 'uptime' -e ansible\_python\_interpreter='"/usr/bin/env python"'

where jail1 is the jail name.

Regards,  
meka

---

<div class="post-metadata">

**Author:** ![Michael\_Weinrich](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Michael\_Weinrich](https://forum.ansible.com/u/Michael_Weinrich)\
**Post date:** [November 22, 2016, 10:06am UTC](https://forum.ansible.com/t/bsd-jexec-module/23040/4 "2016-11-22T10:06:13Z")

</div>

I was looking for a way to provision jails on my FreeNAS box however I can’t make your command work. Using the jail connection type only works on the host having the jails? In which way did you use the command you provided?

Thanks,  
Michael

---

<div class="post-metadata">

**Author:** ![Goran\_Mekic](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@Goran\_Mekic](https://forum.ansible.com/u/Goran_Mekic)\
**Post date:** [November 22, 2016, 10:14am UTC](https://forum.ansible.com/t/bsd-jexec-module/23040/5 "2016-11-22T10:14:45Z")

</div>

Yes, that's the command for host running jails. I would love to be able to run it over SSH, of course. Is it even possible?

Regards,  
meka
