# Adding support for acting on a local chroot

**URL:** <https://forum.ansible.com/t/adding-support-for-acting-on-a-local-chroot/12349>\
**Category:** Ansible Project\
**Created:** [February 13, 2013, 10:28am UTC](https://forum.ansible.com/t/adding-support-for-acting-on-a-local-chroot/12349 "2013-02-13T10:28:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maykel\_Moya](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Maykel\_Moya](https://forum.ansible.com/u/Maykel_Moya)\
**Post date:** [February 13, 2013, 10:28am UTC](https://forum.ansible.com/t/adding-support-for-acting-on-a-local-chroot/12349/1 "2013-02-13T10:28:12Z")

</div>

Hello

I'd like to use Ansible to configure a local chroot (ex: a deboostrap)  
for easing management/generation of virtual OSes images. With respect to  
'ansible chroot' all I got was issue 1097.

Taking mpdehaan suggestion of 'chroot: /path/to/chroot'[1] I've uploaded  
a proof of concept[2]. There are many things missing by now (check  
directoy existence, play nice with sudo, check euid == 0 for chrooting,  
test more complex playbooks, etc...), I'd like to hear some feedback.

Playbook[3] I'm playing with and output of playbook run[4]. I'm able to  
get facts with '-m setup' as well[5].

While doing this I got a traceback because '/proc' is not necessarily  
mounted inside a chroot. There are two fixed for that in [6] and [7].

Regards,  
maykel

[1] [https://github.com/ansible/ansible/issues/1097#issuecomment-8888954](https://github.com/ansible/ansible/issues/1097#issuecomment-8888954)  
[2] [http://git.io/CqHtaQ](http://git.io/CqHtaQ)  
[3] [http://pastebin.com/PzrJFVDY](http://pastebin.com/PzrJFVDY)  
[4] [http://pastebin.com/GkVjqPmc](http://pastebin.com/GkVjqPmc)  
[5] [http://pastebin.com/9kn9PFJP](http://pastebin.com/9kn9PFJP)  
[6] [http://git.io/sY4qmQ](http://git.io/sY4qmQ)  
[7] [http://git.io/QD1rJw](http://git.io/QD1rJw)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 13, 2013, 1:16pm UTC](https://forum.ansible.com/t/adding-support-for-acting-on-a-local-chroot/12349/2 "2013-02-13T13:16:50Z")

</div>

If this works, I'm game.

It should probably raise an error if you try to use the chroot option  
with another connection type, I think.

(Would love to see an example playbook and some basic instructions for  
testing it out)

Thanks!

---

<div class="post-metadata">

**Author:** ![Maykel\_Moya](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Maykel\_Moya](https://forum.ansible.com/u/Maykel_Moya)\
**Post date:** [February 14, 2013, 11:18am UTC](https://forum.ansible.com/t/adding-support-for-acting-on-a-local-chroot/12349/3 "2013-02-14T11:18:08Z")

</div>

PR 2082 filled including both example playbook an basic instructions.

Regards,  
maykel

---

<div class="post-metadata">

**Author:** ![Dag\_Wieers](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dag\_Wieers](https://forum.ansible.com/u/Dag_Wieers)\
**Post date:** [February 20, 2013, 3:04pm UTC](https://forum.ansible.com/t/adding-support-for-acting-on-a-local-chroot/12349/4 "2013-02-20T15:04:22Z")

</div>

The more I think about this, the more I wonder if 'chroot' shouldn't become a connection type itself. (connection types would need to become configurable per target to make it useful beyond just chroots)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 20, 2013, 3:08pm UTC](https://forum.ansible.com/t/adding-support-for-acting-on-a-local-chroot/12349/5 "2013-02-20T15:08:03Z")

</div>

Right, the discussion on the ticket is about doing exactly that,  
making it a connection type.
