def new_user(admin_username, admin_password): env.user = 'root' # Create the admin group and add it to the sudoers file admin_group = 'admin' runcmd('addgroup {group}'.format(group=admin_group)) runcmd('echo "%{group} ALL=(ALL) ALL" >> /etc/sudoers'.format( group=admin_group)) # Create the new admin user (default group=username); add to admin group runcmd('adduser {username} --disabled-password --gecos ""'.format( username=admin_username)) runcmd('adduser {username} {group}'.format( username=admin_username, group=admin_group)) # Set the password for the new admin user runcmd('echo "{username}:{password}" | chpasswd'.format( username=admin_username, password=admin_password))