# Are there any working examples of using community.general.jail

**URL:** <https://forum.ansible.com/t/are-there-any-working-examples-of-using-community-general-jail/3071>\
**Category:** Get Help\
**Tags:** collections\
**Created:** [December 27, 2023, 2:32am UTC](https://forum.ansible.com/t/are-there-any-working-examples-of-using-community-general-jail/3071 "2023-12-27T02:32:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![feurig](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/feurig/32/1871_2.png) [@feurig](https://forum.ansible.com/u/feurig)\
**Post date:** [December 27, 2023, 2:32am UTC](https://forum.ansible.com/t/are-there-any-working-examples-of-using-community-general-jail/3071/1 "2023-12-27T02:32:33Z")

</div>

We have several freebsd jails that do not have ssh connectivity.  
Can we use the jail connection the same way that we use the lxd one.  
I have root connectivity on the jail hosts but the connection doesn’t work the same way.

---

<div class="post-metadata">

**Author:** ![feurig](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/feurig/32/1871_2.png) [@feurig](https://forum.ansible.com/u/feurig)\
**Post date:** [January 5, 2024, 1:23am UTC](https://forum.ansible.com/t/are-there-any-working-examples-of-using-community-general-jail/3071/2 "2024-01-05T01:23:12Z")

</div>

On my lxd hosts I use an inventory file like this.

```auto
[containers:children]
local_containers
remote_containers
[containers:vars]
ansible_connection=lxd

[local_containers]
jules ip_address=198.202.31.135 purpose="Squid Server"
...
[remote_containers]
teddy ip_address=198.202.31.132 purpose="Secondary DNS" ansible_host=aoc2024:teddy

```

And everything just works.

I have not figured out how to make the jail connection work in the same way.

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [January 5, 2024, 12:32pm UTC](https://forum.ansible.com/t/are-there-any-working-examples-of-using-community-general-jail/3071/3 "2024-01-05T12:32:12Z")

</div>

I’ve not used the [community.general.jail connection](https://docs.ansible.com/ansible/latest/collections/community/general/jail_connection.html) however if it works like the [community.general.chroot connection](https://docs.ansible.com/ansible/latest/collections/community/general/chroot_connection.html) where the Ansible playbook needs to be run on the same host that the chroot exists on, it can’t be run via SSH, perhaps this is also the case for `community.general.jail`? 🤷‍♂️

An example YAML inventory file (sorry I don’t have an example in the INI format) for use with `community.general.chroot`, note that the `inventory_hostname` is the path to the directory for the chroot:

```yaml
---
all:
  children:
    chroots:
      vars:
        ansible_connection: community.general.chroot
      hosts:
        /chroot:
    localhosts:
      vars:
        ansible_connection: local
      hosts:
        localhost:
...

```

For reasons I’ve not worked out the [Implicit ‘localhost’](https://docs.ansible.com/ansible/latest/inventory/implicit_localhost.html) feature hasn’t been working for me recently without is also being added to the inventory.
