Ver código fonte

AMBARI-414. Add rpm spec for hmc agent. (Contributed by Mahadev)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1347217 13f79535-47bb-0310-9956-ffa450edef68
Vikram Dixit K 13 anos atrás
pai
commit
04710ca7e2

+ 2 - 0
CHANGES.txt

@@ -6,6 +6,8 @@ characters wide.
 
 
 Release 0.1.x - unreleased
 Release 0.1.x - unreleased
 
 
+  AMBARI-414. Add rpm spec for hmc agent. (Mahadev via Vikram)
+
   AMBARI-409. Uninstall does not get full list of hosts. (Vikram)
   AMBARI-409. Uninstall does not get full list of hosts. (Vikram)
 
 
   AMBARI-410. Need to move the creation of cluster directory for hosting the key file and the nodes file to add nodes. (Vikram)
   AMBARI-410. Need to move the creation of cluster directory for hosting the key file and the nodes file to add nodes. (Vikram)

+ 11 - 4
hmc/ShellScripts/puppet_agent_install.sh

@@ -139,7 +139,7 @@ host=`hostname -f | tr '[:upper:]' '[:lower:]'`
 out=`/etc/init.d/iptables stop 1>/dev/null`
 out=`/etc/init.d/iptables stop 1>/dev/null`
 
 
 echo "Installing puppet using yum"
 echo "Installing puppet using yum"
-out=`yum install -y puppet-2.7.9-2`
+out=`yum install -y hmc-agent`
 ret=$?
 ret=$?
 if [[ "$ret" != "0" ]]; then
 if [[ "$ret" != "0" ]]; then
   echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2
   echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2
@@ -153,7 +153,7 @@ if [[ "$ret" != "0" ]]; then
   echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2
   echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2
   exit 1
   exit 1
 fi
 fi
-
+out=`echo $master > /etc/hmc/hmc-agent.conf`
 out=`mkdir -p /etc/puppet/agent 2>&1`
 out=`mkdir -p /etc/puppet/agent 2>&1`
 agent_auth_conf="path /run\nauth any\nallow $master\n\npath /\nauth any"
 agent_auth_conf="path /run\nauth any\nallow $master\n\npath /\nauth any"
 out=`echo -e $agent_auth_conf > /etc/puppet/agent/auth.conf`
 out=`echo -e $agent_auth_conf > /etc/puppet/agent/auth.conf`
@@ -168,14 +168,21 @@ fi
 
 
 #TODO clean this up for better fix. For now make sure we stop puppet agent. The issue here is we do not know if we started this puppet agent during our run or not.
 #TODO clean this up for better fix. For now make sure we stop puppet agent. The issue here is we do not know if we started this puppet agent during our run or not.
 echo "Stopping puppet agent using service stop command"
 echo "Stopping puppet agent using service stop command"
-out=`service puppet stop`
+out=`service hmc-agent stop`
 ret=$?
 ret=$?
 
 
 echo "Starting puppet agent for HMC"
 echo "Starting puppet agent for HMC"
-out=`puppet agent --verbose --confdir=/etc/puppet/agent --listen --runinterval 5 --server $master --report --no-client --waitforcert 10 --configtimeout 600 --debug --logdest=/var/log/puppet_agent.log --httplog /var/log/puppet_agent_http.log --autoflush --use_cached_catalog 2>&1`
+out=`service hmc-agent start`
 ret=$?
 ret=$?
 if [[ "$ret" != "0" ]]; then
 if [[ "$ret" != "0" ]]; then
   echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2
   echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2
   exit 1
   exit 1
 fi
 fi
+echo "Setting chkconfig for HMC"
+out=`chkconfig --add hmc-agent`
+ret=$?
+#if [[ "$ret" != "0" ]]; then
+#  echo "$host:_ERROR_:retcode:[$ret], CMD:[$pp_cmd]: OUT:[$out]" >&2
+#  exit 1
+#fi
 exit 0
 exit 0

+ 7 - 0
hmc/package/rpm/SOURCES/hmc_hdp.repo

@@ -7,6 +7,13 @@ enabled=1
 gpgcheck=0
 gpgcheck=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
 
 
+[HDP-1.0.11]
+name=Hortonworks Data Platform Version - HDP-1.0.11
+baseurl=http://s3.amazonaws.com/temp.repo/HDP-1.0.11/repos/centos5
+gpgcheck=0
+enabled=1
+priority=1
+
 [Puppet]
 [Puppet]
 name=Puppet
 name=Puppet
 baseurl = http://yum.puppetlabs.com/el/5/products/x86_64/
 baseurl = http://yum.puppetlabs.com/el/5/products/x86_64/

+ 24 - 6
hmc/package/rpm/SPECS/hmc.spec

@@ -33,7 +33,8 @@ Group: System Environment/Base
 Source: %{name}-%{version}.tar.gz
 Source: %{name}-%{version}.tar.gz
 Source1: hmc.init.in
 Source1: hmc.init.in
 Source2: hmc_hdp.repo
 Source2: hmc_hdp.repo
-Buildroot: %{_tmppath}/%{name}-%{version}-buildroot
+Source3: hmc-agent.init.in
+BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
 Requires: php >= 5, sqlite >= 3, php-pdo, php-pecl-json, httpd, puppet = 2.7.9, pdsh, httpd-devel, ruby-devel, rubygems, mod_passenger, mod_ssl
 Requires: php >= 5, sqlite >= 3, php-pdo, php-pecl-json, httpd, puppet = 2.7.9, pdsh, httpd-devel, ruby-devel, rubygems, mod_passenger, mod_ssl
 %define web_prefixdir %{_prefix}/share/hmc
 %define web_prefixdir %{_prefix}/share/hmc
 %define httpd_confdir %{_sysconfdir}/httpd/conf.d
 %define httpd_confdir %{_sysconfdir}/httpd/conf.d
@@ -42,16 +43,26 @@ Requires: php >= 5, sqlite >= 3, php-pdo, php-pecl-json, httpd, puppet = 2.7.9,
 %define hmc_db_dir %{_var}/db/hmc
 %define hmc_db_dir %{_var}/db/hmc
 %define hmc_run_dir %{_var}/run/hmc
 %define hmc_run_dir %{_var}/run/hmc
 %define hmc_log_dir %{_var}/log/hmc
 %define hmc_log_dir %{_var}/log/hmc
-BuildArchitectures: noarch
+%define hmc_agent_dir %{_sysconfdir}/hmc
+BuildArch: noarch
+
 
 
 %description
 %description
 This package provides a Management Console for Hadoop Cluster.
 This package provides a Management Console for Hadoop Cluster.
 
 
+%package agent
+Summary: agent for hmc
+Group:  System/Daemons
+Requires: puppet = 2.7.9 
+BuildArch: noarch
+%description agent
+This package provides a Management Console for Hadoop Cluster. 
+
+
 %prep
 %prep
 %setup -q -n %{name}-%{version}
 %setup -q -n %{name}-%{version}
 
 
 %build
 %build
-
 %pre
 %pre
 # Make a backup of existing database before installing new package
 # Make a backup of existing database before installing new package
 if [ -f /var/db/hmc/data/data.db ]; then
 if [ -f /var/db/hmc/data/data.db ]; then
@@ -59,10 +70,12 @@ if [ -f /var/db/hmc/data/data.db ]; then
   mv /var/db/hmc/data/data.db /var/db/hmc/data/data.db.$DATE
   mv /var/db/hmc/data/data.db /var/db/hmc/data/data.db.$DATE
 fi
 fi
 
 
+
 %install
 %install
 # Flush any old RPM build root
 # Flush any old RPM build root
 %__rm -rf $RPM_BUILD_ROOT
 %__rm -rf $RPM_BUILD_ROOT
 %__install -D -m0755 "%{SOURCE1}" "$RPM_BUILD_ROOT/etc/init.d/%{name}"
 %__install -D -m0755 "%{SOURCE1}" "$RPM_BUILD_ROOT/etc/init.d/%{name}"
+%__install -D -m0755 "%{SOURCE3}" "$RPM_BUILD_ROOT/etc/init.d/%{name}-agent"
 %__mkdir -p $RPM_BUILD_ROOT/usr/lib/ruby/site_ruby/1.8/puppet/reports/
 %__mkdir -p $RPM_BUILD_ROOT/usr/lib/ruby/site_ruby/1.8/puppet/reports/
 %__mkdir -p $RPM_BUILD_ROOT/%{web_prefixdir}/
 %__mkdir -p $RPM_BUILD_ROOT/%{web_prefixdir}/
 %__mkdir -p $RPM_BUILD_ROOT/%{web_prefixdir}/bin/
 %__mkdir -p $RPM_BUILD_ROOT/%{web_prefixdir}/bin/
@@ -97,6 +110,7 @@ fi
 %__install -D -m0755 puppet/reports/get_revision $RPM_BUILD_ROOT/%{web_prefixdir}/bin
 %__install -D -m0755 puppet/reports/get_revision $RPM_BUILD_ROOT/%{web_prefixdir}/bin
 %__cp -rf puppet/reports/hmcreport.rb $RPM_BUILD_ROOT/usr/lib/ruby/site_ruby/1.8/puppet/reports/
 %__cp -rf puppet/reports/hmcreport.rb $RPM_BUILD_ROOT/usr/lib/ruby/site_ruby/1.8/puppet/reports/
 echo "Alias /hdp %{_prefix}/share/hdp" > $RPM_BUILD_ROOT/%{httpd_confdir}/hdp_mon_dashboard.conf
 echo "Alias /hdp %{_prefix}/share/hdp" > $RPM_BUILD_ROOT/%{httpd_confdir}/hdp_mon_dashboard.conf
+ 
 
 
 %post
 %post
 if test X"$RPM_INSTALL_PREFIX0" = X"" ; then
 if test X"$RPM_INSTALL_PREFIX0" = X"" ; then
@@ -122,7 +136,7 @@ host=`hostname -f | tr '[:upper:]' '[:lower:]'`
 sed -i "s/__TODO_HOSTNAME__/$host/g" /etc/httpd/conf.d/puppetmaster.conf
 sed -i "s/__TODO_HOSTNAME__/$host/g" /etc/httpd/conf.d/puppetmaster.conf
 cp $RPM_INSTALL_PREFIX0/share/hmc/puppet/conf/puppet.conf.template /etc/puppet/puppet.conf
 cp $RPM_INSTALL_PREFIX0/share/hmc/puppet/conf/puppet.conf.template /etc/puppet/puppet.conf
 echo 0 > /selinux/enforce
 echo 0 > /selinux/enforce
-htpasswd -mbc /etc/hmc/htpasswd.users hmcadmin hmcadmin
+htpasswd -mbc /etc/hmc/htpasswd.users hmcadmin hmcadmin &> /dev/null
 #chown apache:apache /var/db/hmc/data/data.db
 #chown apache:apache /var/db/hmc/data/data.db
 chown -R puppet:apache /etc/hmc
 chown -R puppet:apache /etc/hmc
 
 
@@ -145,9 +159,13 @@ rm -rf /var/run/hmc/puppetmaster.boot
 %{hmc_db_dir}
 %{hmc_db_dir}
 %{hmc_log_dir}
 %{hmc_log_dir}
 %{hmc_run_dir}/*
 %{hmc_run_dir}/*
-%clean
-%__rm -rf $RPM_BUILD_ROOT
 
 
+%files agent
+/etc/init.d/hmc-agent
+%{hmc_agent_dir}
+
+#%clean
+#%__rm -rf $RPM_BUILD_ROOT
 %changelog
 %changelog
 * Wed Apr 04 2012 Hortonworks <ambari-group@hortonworks.com>
 * Wed Apr 04 2012 Hortonworks <ambari-group@hortonworks.com>
 - Initial version
 - Initial version

+ 7 - 4
hmc/package/rpm/create_hmc_rpm.sh

@@ -72,7 +72,11 @@ mkdir -p ${RPM_BUILDDIR}/SRPMS/
 
 
 cp -f ${BASEDIR}/SPECS/${PKG_NAME}.spec ${RPM_BUILDDIR}/SPECS/
 cp -f ${BASEDIR}/SPECS/${PKG_NAME}.spec ${RPM_BUILDDIR}/SPECS/
 cp -f ${TAR_DEST} ${RPM_BUILDDIR}/SOURCES/
 cp -f ${TAR_DEST} ${RPM_BUILDDIR}/SOURCES/
-cp -f ${BASEDIR}/SOURCES/* ${RPM_BUILDDIR}/SOURCES/
+cp -f ${BASEDIR}/SOURCES/${PKG_NAME}_hdp.repo ${RPM_BUILDDIR}/SOURCES/
+cp -f ${BASEDIR}/SOURCES/${PKG_NAME}.init.in ${RPM_BUILDDIR}/SOURCES/
+cp -f ${BASEDIR}/SOURCES/${PKG_NAME}-agent.init.in ${RPM_BUILDDIR}/SOURCES/
+
+
 
 
 cd ${RPM_BUILDDIR}
 cd ${RPM_BUILDDIR}
 
 
@@ -88,10 +92,9 @@ if [[ "$ret" != "0" ]]; then
 fi
 fi
 
 
 cd ${CUR_DIR}
 cd ${CUR_DIR}
-
 RPM_DEST=`find ${RPM_BUILDDIR}/{SRPMS,RPMS} -name *.noarch.rpm`
 RPM_DEST=`find ${RPM_BUILDDIR}/{SRPMS,RPMS} -name *.noarch.rpm`
-if [[ ! -f "${RPM_DEST}" ]]; then
-  echo "Error: ${RPM_DEST} does not exist"
+if [[ -z "${RPM_DEST}" ]]; then
+  echo "Error: RPM_DEST dir is empty"
   exit 1
   exit 1
 fi
 fi