I would like to develop Ambari plugin for deploying some services (something like this https://github.com/tzolov/elasticsearch-yarn-ambari-plugin).
I would like to ask for good practices for developing/debugging.
Currently we do delete and copy new files to AMBARI_SERVER_SERVICE_PATH/services/ and then ambari-agent stop && ambari-server stop && ambari-server reset --silent && ambari-server start && ambari-agent start
and I don't feel it like nice solution.
Do you have any good tips, recommendations, links?
The proper term is Ambari Custom Service and not plugin.
The following sequence is the best approach I've found so far in developing custom services. Lets say you're developing custom service 'FOO'.
1) Extract your foo service to the stack you're developing for. For this eg. I will assume HDP 2.4:
tar -xzvf foo_service.tgz -C /var/lib/ambari-server/resources/stacks/HDP/2.4/services/FOO
2) Restart ambari-server to pick up the stack changes
sudo ambari-server restart
3) Use the Ambari UI service install wizard to install your custom service.
4) Do your testing and debugging, make any changes to your custom service descriptor files.
5) Stop your service and all of its components using the Ambari UI.
6) Uninstall your service from Ambari using something similar to the remove-service.sh
script below.
7) Re-install your modified service, starting at step 1. Rinse and Repeat.
remove-service.sh:
#!/usr/bin/env bash
host=localhost
cluster=hdp
port=8080
user=admin
password='admin'
echo "Deleting the FOO service..."
curl -i -H "X-Requested-By: ambari" -u $user:$password -X DELETE http://$host:$port/api/v1/clusters/$cluster/services/FOO
NOTE: Sometimes this approach will not work if you're custom service fails to install correctly. In that scenario you sometimes have to make corrections to your descriptor files, restart ambari-server, and then use the ambari rest API to re-install your service. Using the service install wizard to re-install will not work in this scenario. See the ambari wiki for more details on how to use the rest api to re-install the service.
A lot of useful information can be found on developing custom ambari services and the ambari rest api on the Ambari Wiki.