BSD jexec module

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

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

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

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

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