# is a new shell created for each task in a playbook?

**URL:** <https://forum.ansible.com/t/is-a-new-shell-created-for-each-task-in-a-playbook/20522>\
**Category:** Ansible Project\
**Created:** [February 10, 2016, 7:01pm UTC](https://forum.ansible.com/t/is-a-new-shell-created-for-each-task-in-a-playbook/20522 "2016-02-10T19:01:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrono](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@chrono](https://forum.ansible.com/u/chrono)\
**Post date:** [February 10, 2016, 7:01pm UTC](https://forum.ansible.com/t/is-a-new-shell-created-for-each-task-in-a-playbook/20522/1 "2016-02-10T19:01:18Z")

</div>

The environment I work in has sudo locked down so you cannot execute /bin/sh using sudo, which is a huge issue because that is exactly what ansible tries to do.

From looking at the output of playbook execution with the -vvvv flag, it seems to me that each task is run in a new ssh session and new shell. Is that correct?

---

<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:** [February 10, 2016, 8:41pm UTC](https://forum.ansible.com/t/is-a-new-shell-created-for-each-task-in-a-playbook/20522/2 "2016-02-10T20:41:13Z")

</div>

yes, each task runs by issuing a new ssh connection and passing a new shell command.

ansible does not currently work with sudo restricted to specific commands:  
[http://docs.ansible.com/ansible/become.html#sudo-and-su-still-work](http://docs.ansible.com/ansible/become.html#sudo-and-su-still-work) (check notes)
