def sudoer(username, hosts="ALL", operators="ALL", passwd=False,
           commands="ALL"):
    tags = "PASSWD:" if passwd else "NOPASSWD:"
    spec = "%(username)s %(hosts)s=(%(operators)s) %(tags)s %(commands)s" %\
           locals()
    filename = '/etc/sudoers.d/fabtools-%s' % username
    if is_file(filename):
        run_as_root('chmod 0640 %(filename)s && rm -f %(filename)s' % locals())
    run_as_root('echo "%(spec)s" >%(filename)s && chmod 0440 %(filename)s' %
                locals(), shell=True)
Require sudo permissions for a given user.
dataset/ETHPy150Open ronnix/fabtools/fabtools/require/users.py/sudoer