# FreeBSD Jails support (cron, service, user, group)

**URL:** <https://forum.ansible.com/t/freebsd-jails-support-cron-service-user-group/18979>\
**Category:** Ansible Developer\
**Created:** [August 10, 2015, 1:01pm UTC](https://forum.ansible.com/t/freebsd-jails-support-cron-service-user-group/18979 "2015-08-10T13:01:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evgeny\_Lyapin](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@Evgeny\_Lyapin](https://forum.ansible.com/u/Evgeny_Lyapin)\
**Post date:** [August 10, 2015, 1:01pm UTC](https://forum.ansible.com/t/freebsd-jails-support-cron-service-user-group/18979/1 "2015-08-10T13:01:09Z")

</div>

I would appreciate if Ansible development team support FreeBSD jails in system modules (cron, user, group, service). The idea is to add a parameter ‘wrapper’ exec command where necessary - jexec or just chroot, the second parameter will be ‘rootdir’ to specify the root path to jail.

Example of service module:  
service: name=nginx state=started rootdir={{ rootdir }} wrapper=‘{{ wrapper }}’

Ansible user would write “wrapper” himself. Example of “wrapper”:

#!/usr/local/bin/python

# -_- coding: utf-8 -_-

import sys,os,subprocess,re

len(sys.argv) \> 2 or sys.exit(‘Number of arguments must be \> 2’)  
jname = sys.argv[1]  
exestr = ‘’  
jid = 0  
ret = -1

exestr = ’ '.join(sys.argv[2:])

def runProcess(exe):  
p = subprocess.Popen(exe, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)  
retcode = p.wait()  
if retcode: sys.exit(ret)  
return p.stdout.readlines()

for line in runProcess(‘jls’):  
line = line.strip()  
if re.match(‘JID’, line): continue  
m = line.split()  
if m[2] == jname:  
jid = m[0]  
break

if jid \> 0:  
status = os.system(‘echo '’ + exestr + ‘' | jexec ’ + jid + ’ sh’)

ret = os.WEXITSTATUS(status)  
if ret is None: ret = 0

sys.exit(ret)

I wrote forks of these system modules (cron, user, group, service), but I would like not to patch ansible when version is up. So I could push my pieces of code to Ansible git and someone will merge it.

---

<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:** [August 10, 2015, 1:06pm UTC](https://forum.ansible.com/t/freebsd-jails-support-cron-service-user-group/18979/2 "2015-08-10T13:06:29Z")

</div>

We have a jails connection plugin that removes the need to support  
jails in every possible module.

---

<div class="post-metadata">

**Author:** ![Evgeny\_Lyapin](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@Evgeny\_Lyapin](https://forum.ansible.com/u/Evgeny_Lyapin)\
**Post date:** [August 11, 2015, 3:34pm UTC](https://forum.ansible.com/t/freebsd-jails-support-cron-service-user-group/18979/3 "2015-08-11T15:34:41Z")

</div>

It’s local connector, but we need remote jail connector. Example is BSDploy, but it use ezjail which is not a part of FreeBSD base system. I continue to argue It’s very good deal to expand jail support for system modules.
