# Use pfexec instead of sudo

**URL:** <https://forum.ansible.com/t/use-pfexec-instead-of-sudo/14472>\
**Category:** Ansible Project\
**Created:** [January 31, 2014, 11:19pm UTC](https://forum.ansible.com/t/use-pfexec-instead-of-sudo/14472 "2014-01-31T23:19:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Wolstenholme](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@Paul\_Wolstenholme](https://forum.ansible.com/u/Paul_Wolstenholme)\
**Post date:** [January 31, 2014, 11:19pm UTC](https://forum.ansible.com/t/use-pfexec-instead-of-sudo/14472/1 "2014-01-31T23:19:05Z")

</div>

Is it possible to specify pfexec instead of sudo in a playbook. Something like:

sudo\_command: pfexec  
or  
root\_command: pfexec

Cheers,  
Paul

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [January 31, 2014, 11:23pm UTC](https://forum.ansible.com/t/use-pfexec-instead-of-sudo/14472/2 "2014-01-31T23:23:43Z")

</div>

If pfexec can take same command line arguments as sudo, use ANSIBLE\_SUDO\_EXE env variable or sudo\_exe entry in ansible .cfg to point to it.

---

<div class="post-metadata">

**Author:** ![Paul\_Wolstenholme](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@Paul\_Wolstenholme](https://forum.ansible.com/u/Paul_Wolstenholme)\
**Post date:** [January 31, 2014, 11:45pm UTC](https://forum.ansible.com/t/use-pfexec-instead-of-sudo/14472/3 "2014-01-31T23:45:03Z")

</div>

Thanks Brian. I’ll give that a try. Although, I would like to use both. We have both linux and smartos boxes we would like to do specify within the context of a playbook or inventory file. sudo will work on Smartos but pfexec seems to be prefered in the Solaris world.

Cheers,  
Paul

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 31, 2014, 11:52pm UTC](https://forum.ansible.com/t/use-pfexec-instead-of-sudo/14472/4 "2014-01-31T23:52:07Z")

</div>

It’s currently not configurable on a per inventory variable basis, but patches to add a ansible\_sudo\_exe parameter would be considered for sure.

---

<div class="post-metadata">

**Author:** ![Preston\_Marshall](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@Preston\_Marshall](https://forum.ansible.com/u/Preston_Marshall)\
**Post date:** [February 12, 2015, 9:40pm UTC](https://forum.ansible.com/t/use-pfexec-instead-of-sudo/14472/5 "2015-02-12T21:40:14Z")

</div>

Did you ever solve this Paul? I am struggling with the same issue.

---

<div class="post-metadata">

**Author:** ![Paul\_Wolstenholme](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@Paul\_Wolstenholme](https://forum.ansible.com/u/Paul_Wolstenholme)\
**Post date:** [February 13, 2015, 7:17pm UTC](https://forum.ansible.com/t/use-pfexec-instead-of-sudo/14472/6 "2015-02-13T19:17:33Z")

</div>

No. As much as I prefer rbac and pfexec, I just started using sudo. There is a hard-coded switch (-Z|z) that messes it up.

I do want to revisit the issue but I haven’t had time.

Cheers,  
Paul
