├── .gitignore ├── README.md ├── configuration └── ntpd-config.xml ├── metainfo.xml ├── package └── scripts │ ├── client.py │ ├── master.py │ └── params.py └── screenshots ├── 1.png ├── 10.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png └── 9.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Ambari 2 | .hash 3 | archive.zip 4 | # Java 5 | .DS_Store 6 | .class 7 | # Various editors swap files 8 | .*.sw? 9 | *~ 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### An Ambari Stack for NTPD 2 | Ambari stack for easily installing and managing NTPD on HDP cluster 3 | 4 | Limitations: 5 | 6 | - This is not an officially supported service and *is not meant to be deployed in production systems*. It is only meant for testing demo/purposes 7 | - It does not support Ambari/HDP upgrade process and will cause upgrade problems if not removed prior to upgrade 8 | 9 | Steps: 10 | 11 | - Download HDP 2.2 sandbox VM image (Sandbox_HDP_2.2_VMware.ova) from [Hortonworks website](http://hortonworks.com/products/hortonworks-sandbox/) 12 | - Import Sandbox_HDP_2.2_VMware.ova into VMWare and set the VM memory size to 8GB 13 | - Now start the VM 14 | - After it boots up, find the IP address of the VM and add an entry into your machines hosts file e.g. 15 | ``` 16 | 192.168.191.241 sandbox.hortonworks.com sandbox 17 | ``` 18 | - Connect to the VM via SSH (password hadoop) and start Ambari server 19 | ``` 20 | ssh root@sandbox.hortonworks.com 21 | /root/start_ambari.sh 22 | ``` 23 | 24 | - To deploy the NTPD stack, run below 25 | ``` 26 | VERSION=`hdp-select status hadoop-client | sed 's/hadoop-client - \([0-9]\.[0-9]\).*/\1/'` 27 | sudo git clone https://github.com/abajwa-hw/ntpd-stack.git /var/lib/ambari-server/resources/stacks/HDP/$VERSION/services/NTPD-DEMO 28 | 29 | sudo service ambari restart 30 | ``` 31 | - Then you can click on 'Add Service' from the 'Actions' dropdown menu in the bottom left of the Ambari dashboard: 32 | 33 | On bottom left -> Actions -> Add service -> check NTPD service -> Next -> Next -> Next -> Deploy 34 | ![Image](../master/screenshots/1.png?raw=true) 35 | ![Image](../master/screenshots/2.png?raw=true) 36 | ![Image](../master/screenshots/3.png?raw=true) 37 | ![Image](../master/screenshots/4.png?raw=true) 38 | ![Image](../master/screenshots/5.png?raw=true) 39 | ![Image](../master/screenshots/6.png?raw=true) 40 | ![Image](../master/screenshots/7.png?raw=true) 41 | ![Image](../master/screenshots/8.png?raw=true) 42 | 43 | - On successful deployment you will see the NTPD service as part of Ambari stack and will be able to start/stop the service from here: 44 | ![Image](../master/screenshots/9.png?raw=true) 45 | 46 | - You can see the parameters you configured under 'Configs' tab 47 | ![Image](../master/screenshots/10.png?raw=true) 48 | 49 | 50 | #### Use ntpd service 51 | 52 | - Check the contents of the ntpd log file we specified 53 | ``` 54 | # cat /var/log/ntpd.log 55 | Starting ntpd: [ OK ] 56 | ``` 57 | 58 | - Use ntpd service 59 | ``` 60 | # service ntpd status 61 | ntpd (pid 9180) is running... 62 | ``` 63 | 64 | - One benefit to wrapping the component in Ambari service is that you can now monitor/manage this service remotely via REST API 65 | ``` 66 | export SERVICE=NTPD 67 | export PASSWORD=admin 68 | export AMBARI_HOST=sandbox.hortonworks.com 69 | export CLUSTER=Sandbox 70 | 71 | #get service status 72 | curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X GET http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE 73 | 74 | #start service 75 | curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Start $SERVICE via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE 76 | 77 | #stop service 78 | curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"Stop $SERVICE via REST"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER/services/$SERVICE 79 | ``` 80 | 81 | #### Remove ntpd service 82 | 83 | - To remove the NTPD service: 84 | - Stop the service via Ambari 85 | - Delete the service 86 | 87 | ``` 88 | curl -u admin:admin -i -H 'X-Requested-By: ambari' -X DELETE http://sandbox.hortonworks.com:8080/api/v1/clusters/Sandbox/services/NTPD 89 | ``` 90 | - Remove artifacts 91 | 92 | ``` 93 | rm -rf /var/lib/ambari-server/resources/stacks/HDP/2.2/services/ntpd-stack 94 | ``` 95 | - Restart Ambari 96 | ``` 97 | service ambari restart 98 | ``` 99 | -------------------------------------------------------------------------------- /configuration/ntpd-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | ntpd.log 14 | /var/log/ntpd.log 15 | Log file for ntpd service 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /metainfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2.0 4 | 5 | 6 | 7 | NTPD 8 | 9 | ntpd 10 | 11 | The Network Time Protocol daemon (ntpd) is an operating system program that maintains the system time in synchronization with time servers using the Network Time Protocol. This service is for <b>Demo purposes only</b> and is <b>not officially supported</b> 12 | 13 | 0.1.0 14 | 15 | 16 | 17 | NTPD_MASTER 18 | ntpd 19 | MASTER 20 | 21 | 1+ 22 | 23 | 24 | 25 | PYTHON 26 | 600 27 | 28 | 29 | 30 | NTP_CLIENT 31 | ntpdate 32 | CLIENT 33 | 34 | 1+ 35 | 36 | 37 | 38 | PYTHON 39 | 600 40 | 41 | 42 | 43 | 44 | 45 | 46 | redhat6,redhat7 47 | 48 | 49 | ntp 50 | 51 | 52 | ntpdate 53 | 54 | 55 | 56 | 57 | 58 | 59 | ntpd-config 60 | 61 | false 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /package/scripts/client.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from resource_management import * 3 | 4 | class Client(Script): 5 | def install(self, env): 6 | self.install_packages(env) 7 | self.configure(env) 8 | 9 | def configure(self, env): 10 | import params 11 | env.set_params(params) 12 | # This is actually not a service, it just syncs system time instantly 13 | Execute('service ntpdate start') 14 | pass 15 | 16 | # Start means configure for the client 17 | def start(self, env, upgrade_type=None): 18 | import params 19 | env.set_params(params) 20 | self.configure(env) 21 | pass 22 | 23 | # Do nothing, no need to stop the client 24 | def stop(self, env, upgrade_type=None): 25 | pass 26 | 27 | def status(self, env): 28 | raise ClientComponentHasNoStatus() 29 | 30 | if __name__ == "__main__": 31 | Client().execute() 32 | -------------------------------------------------------------------------------- /package/scripts/master.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from resource_management import * 3 | 4 | class Master(Script): 5 | def install(self, env): 6 | # Install packages listed in metainfo.xml 7 | self.install_packages(env) 8 | Execute('echo \'OPTIONS="-g -p /var/run/ntpd.pid"\' > /etc/sysconfig/ntpd') 9 | #if any other install steps were needed they can be added here 10 | 11 | #To stop the service, use the linux service stop command and pipe output to log file 12 | def stop(self, env): 13 | import params 14 | env.set_params(params) 15 | Execute('service ntpd stop >>' + params.stack_log) 16 | Execute('rm -f /var/run/ntpd.pid') 17 | 18 | #To start the service, use the linux service start command and pipe output to log file 19 | def start(self, env): 20 | import params 21 | env.set_params(params) 22 | Execute('service ntpd start >>' + params.stack_log) 23 | 24 | #To get status of the, use the linux service status command 25 | def status(self, env): 26 | 27 | check_process_status('/var/run/ntpd.pid') 28 | 29 | if __name__ == "__main__": 30 | Master().execute() 31 | -------------------------------------------------------------------------------- /package/scripts/params.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from resource_management import * 3 | 4 | # config object that holds the configurations declared in the config xml file 5 | config = Script.get_config() 6 | 7 | # store the log file for the service from the 'ntpd.log' property of the 'ntpd-config.xml' file 8 | stack_log = config['configurations']['ntpd-config']['ntpd.log'] 9 | -------------------------------------------------------------------------------- /screenshots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abajwa-hw/ntpd-stack/198360bc55e3d7f7f2d8087e8d1dd61326bc567e/screenshots/1.png -------------------------------------------------------------------------------- /screenshots/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abajwa-hw/ntpd-stack/198360bc55e3d7f7f2d8087e8d1dd61326bc567e/screenshots/10.png -------------------------------------------------------------------------------- /screenshots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abajwa-hw/ntpd-stack/198360bc55e3d7f7f2d8087e8d1dd61326bc567e/screenshots/2.png -------------------------------------------------------------------------------- /screenshots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abajwa-hw/ntpd-stack/198360bc55e3d7f7f2d8087e8d1dd61326bc567e/screenshots/3.png -------------------------------------------------------------------------------- /screenshots/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abajwa-hw/ntpd-stack/198360bc55e3d7f7f2d8087e8d1dd61326bc567e/screenshots/4.png -------------------------------------------------------------------------------- /screenshots/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abajwa-hw/ntpd-stack/198360bc55e3d7f7f2d8087e8d1dd61326bc567e/screenshots/5.png -------------------------------------------------------------------------------- /screenshots/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abajwa-hw/ntpd-stack/198360bc55e3d7f7f2d8087e8d1dd61326bc567e/screenshots/6.png -------------------------------------------------------------------------------- /screenshots/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abajwa-hw/ntpd-stack/198360bc55e3d7f7f2d8087e8d1dd61326bc567e/screenshots/7.png -------------------------------------------------------------------------------- /screenshots/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abajwa-hw/ntpd-stack/198360bc55e3d7f7f2d8087e8d1dd61326bc567e/screenshots/8.png -------------------------------------------------------------------------------- /screenshots/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abajwa-hw/ntpd-stack/198360bc55e3d7f7f2d8087e8d1dd61326bc567e/screenshots/9.png --------------------------------------------------------------------------------