# question on single playbook or roles?

**URL:** <https://forum.ansible.com/t/question-on-single-playbook-or-roles/37974>\
**Category:** Ansible Project\
**Created:** [May 10, 2023, 3:29pm UTC](https://forum.ansible.com/t/question-on-single-playbook-or-roles/37974 "2023-05-10T15:29:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [May 10, 2023, 3:29pm UTC](https://forum.ansible.com/t/question-on-single-playbook-or-roles/37974/1 "2023-05-10T15:29:25Z")

</div>

I got a few tasks i need to do on esxi host

1. put in maintenace mode
2. copy vib from my laptop to the the host shared datastore
3. install the patch

esxcli softare vib install -d /path/xxx.zip

1. reboot the host
2. take it out of maintenance mode

do i create roles for these or single playbook?

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [May 10, 2023, 3:38pm UTC](https://forum.ansible.com/t/question-on-single-playbook-or-roles/37974/2 "2023-05-10T15:38:00Z")

</div>

If you just want the quickest option then go for a playbook.  
If you can spend some time on this then you could create a role that is meant for patching ESX hosts, and that includes helper tasks to handle the maintenance mode and the reboot.  
Endless possibilities to do this, from quick and dirty to nicely parametrised

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [May 10, 2023, 4:12pm UTC](https://forum.ansible.com/t/question-on-single-playbook-or-roles/37974/3 "2023-05-10T16:12:32Z")

</div>

I agree with Dick. Is this something you will do over and over so taking the time makes sense? Or is this a once-and-done task?

Also look at the tools VMware offers. Ansible isn’t always the right solution.

Walter

---

<div class="post-metadata">

**Author:** ![Kevin\_Knox](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kevin_knox/32/3926_2.png) [@Kevin\_Knox](https://forum.ansible.com/u/Kevin_Knox)\
**Post date:** [May 12, 2023, 3:54pm UTC](https://forum.ansible.com/t/question-on-single-playbook-or-roles/37974/4 "2023-05-12T15:54:57Z")

</div>

Hmmm. My reply did not post. Maybe I replied to the user?

Anyway, my vote is to consider “roles” to be an enhancement. I have to be very certain I’m going to reuse the role before I will create it. If I’m not sure, then I call the creation of a role “gold plating” and unnecessary. So, I will create a straight playbook if there’s any doubt in my mind about whether this is a reusable task. That does mean when the time comes to reuse the tasks that would be in the role, I need to refactor the original play to role-ify it, but that’s pretty light work. I’d rather be certain I don’t gold plate any plays than end up with a bunch of single-use roles cluttering my project.

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [May 12, 2023, 3:56pm UTC](https://forum.ansible.com/t/question-on-single-playbook-or-roles/37974/5 "2023-05-12T15:56:10Z")

</div>

Yes, that was me, LOL.

Even a single playbook can be “parameterized” to use variables you supply via command line or a vars file. That offers reuse.

Walter

---

<div class="post-metadata">

**Author:** ![Kosala\_Atapattu1](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kosala\_Atapattu1](https://forum.ansible.com/u/Kosala_Atapattu1)\
**Post date:** [May 13, 2023, 12:14am UTC](https://forum.ansible.com/t/question-on-single-playbook-or-roles/37974/6 "2023-05-13T00:14:40Z")

</div>

If this is the only thing you’re planning on doing with Ansible, I would go for a single playbook. In my repository, I have roles for enter\_maintenance\_mode and exit\_maintenance\_mode, since that function is used in multiple contexts.

In my environment rather than performing a SSH to ESXi and run esxcli command, which either you need to enable shell each time, or have that turned on permanently, which leaves a security risk,. I’d rather use PowerCLI. PS7 on Linux or Mac works fine with PowerCLI. I keep that to apply Host Profiles and other functions where there are no native vmware modules.

I have a PowerShell / PowerCLI delegate host dedicated for tasks which do not have native modules, and delegate those tasks to the delegate host.

HTH,
