Host hugepages control

Lets assume the following scenario.
You have N hosts where, you want to run group 1 of N VMs with hugepages.
You also want to run another group 2 of N VMs but without hugepages. Not together with group 1.

Right now you need to go and sysctl -w vm.nr_hugepages=xxxx to add required amount.
When done with group 1, you undeploy, then sysctl -w vm.nr_hugepages=0 and then start.

So I thought, not a big issue, will add hook with script.
Look into hook docs see ruby example, put it place. See that it doesn’t work, because nodes don’t have nokogiri. Try to install gem to find that I have to install tons of other shit for this. Drop it and switch script to python.
Get to a working point to find that oneadmin user does not have rights for sysctl. So i guess now I have to add /sbin/sysctl to opennebula sudoers on each node?

And second question is: Is there a better way to handle this?