# Chaining connection plugins

**URL:** <https://forum.ansible.com/t/chaining-connection-plugins/43992>\
**Category:** Get Help\
**Tags:** freebsd\
**Created:** [July 22, 2025, 3:51pm UTC](https://forum.ansible.com/t/chaining-connection-plugins/43992 "2025-07-22T15:51:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![okapi](https://avatars.discourse-cdn.com/v4/letter/o/da6949/32.png) [@okapi](https://forum.ansible.com/u/okapi)\
**Post date:** [July 22, 2025, 3:51pm UTC](https://forum.ansible.com/t/chaining-connection-plugins/43992/1 "2025-07-22T15:51:13Z")

</div>

**Is it possible to chain multiple connection plugins together**. Specifically, I would want ansible to:

- Connect to my jail host with ssh
- Use the jail connection plugin to attach to a jail

Following an example intended for lxc, I set `ansible_host` to the form `host:jail`. However, I just get a message saying “jail connection requires running as root”. Passing `-kuroot`, it will prompt for an SSH password. Is this not working an error on my part, an ansible limitation or perhaps a bug/limitation in the jail connection plugin.

---

<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:** [July 22, 2025, 3:56pm UTC](https://forum.ansible.com/t/chaining-connection-plugins/43992/2 "2025-07-22T15:56:27Z")

</div>

You can run Ansible using Ansible – I have done this for servers with chroots and the chroot connection plugin, I probably haven’t documented it very well but you could look at [this chroot role](https://git.coop/webarch/chroot).

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [July 22, 2025, 5:29pm UTC](https://forum.ansible.com/t/chaining-connection-plugins/43992/3 "2025-07-22T17:29:40Z")

</div>

Connection plugins don’t stack, but you can create an ssh+jail plugin that does both (I believe someone did already), also see lxc/lxd connection plugins.

---

<div class="post-metadata">

**Author:** ![okapi](https://avatars.discourse-cdn.com/v4/letter/o/da6949/32.png) [@okapi](https://forum.ansible.com/u/okapi)\
**Post date:** [July 25, 2025, 1:44pm UTC](https://forum.ansible.com/t/chaining-connection-plugins/43992/4 "2025-07-25T13:44:25Z")

</div>

I found something along those lines at [GitHub - austinhyde/ansible-sshjail: An Ansible connection plugin for provisioning FreeBSD jails remotely](https://github.com/austinhyde/ansible-sshjail)  
The README talking about Python 2.7 was initially a bit concerning but it appears to exist in FreeBSD ports and does work well. The example they give of using `add_host` to add add the jail to the inventory also worked well for my use case along with `import_playbook`.

The other suggestion of running ansible from ansible is interesting and I could see that working in other circumstances but my FreeBSD host systems are very minimal and wouldn’t typically contain a checkout of the playbooks which would be needed.

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [July 25, 2025, 1:46pm UTC](https://forum.ansible.com/t/chaining-connection-plugins/43992/5 "2025-07-25T13:46:38Z")

</div>

also look at `ansible-pull` or create your  
own playbook that does a git checkout of your plays to execute.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 24, 2025, 1:46pm UTC](https://forum.ansible.com/t/chaining-connection-plugins/43992/6 "2025-08-24T13:46:48Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
