How can I grant permissions to specific users to run ambari-server
? Currently, I get
mahmood@cluster:~$ ambari-server
/usr/sbin/ambari-server: line 47: /var/lib/ambari-server/ambari-env.sh: Permission denied
Using python /usr/bin/python
Usage:
{start|stop|restart|setup|setup-jce|upgrade|status|upgradestack|setup-ldap|sync-ldap|set-current|setup-security|setup-sso|refresh-stack-hash|backup|restore|update-host-names|check-database|db-cleanup|enable-stack} [options]
Use <action> --help to get details on options available.
Or, simply invoke ambari-server.py --help to print the options.
Ambari by default is installed for root. Thus you must run it as root. This can be achieved in several ways. I will explain the best way (in my opinion) to do this using sudo.
Overview:
Steps:
sudo groupadd ambari
Grant the group permission to run the command using visudo. Run sudo visudo
and add ONE of the following lines to the end of the file:
%ambari ALL=(ALL) NOPASSWD: /usr/sbin/ambari-server
or
%ambari ALL=(ALL) /usr/sbin/ambari-server
Note: The first option will not require the user to type their password to execute the command. The second option will require them to do so.
Add the appropriate users to the group (eg. joe)
sudo usermod -aG ambari joe
Those users in the ambari group can now execute sudo ambari-server start