From bba92f879ad2f3784130396f05fa171d4b6db134 Mon Sep 17 00:00:00 2001 From: Matt MacGillivray Date: Tue, 22 Jul 2014 11:39:10 -0400 Subject: [PATCH 01/12] - allow script to choose vfabric version instead of hardcoding to 5.3 - allow init.d script to run as a different user as specified during install --- manifests/agent.pp | 14 ++++++++------ templates/hyperic-hqee-agent.init.redhat.erb | 10 ++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index c16149d..a0a10c0 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -16,6 +16,8 @@ $setup_unverifiedcerts = 'yes', $java_home = '/usr/lib/jvm/jre', $unix_jdk_package = 'java-1.7.0-openjdk-devel', + $vfabric_version = '5.3', + $agent_user = 'root', ) { if $::osfamily == 'RedHat' or $::operatingsystem == 'amazon' { @@ -23,18 +25,18 @@ if $use_vmware_repo { $yumrepo_url = $::operatingsystemrelease ? { - /6.?/ => 'http://repo.vmware.com/pub/rhel6/vfabric/5.3/$basearch', - /5.?/ => 'http://repo.vmware.com/pub/rhel5/vfabric/5.3/$basearch', + /6.?/ => "http://repo.vmware.com/pub/rhel6/vfabric/${vfabric_version}/$basearch", + /5.?/ => "http://repo.vmware.com/pub/rhel5/vfabric/${vfabric_version}/$basearch", } - yumrepo { 'vfabric-5.3': + yumrepo { "vfabric-${vfabric_version}": baseurl => $yumrepo_url, - descr => 'VMware vFabric 5.3 - $basearch', + descr => "VMware vFabric ${vfabric_version} - $basearch", enabled => '1', gpgcheck => '0', } - Yumrepo['vfabric-5.3'] -> Package['vfabric-hyperic-agent'] + Yumrepo["vfabric-${vfabric_version}"] -> Package['vfabric-hyperic-agent'] } package { 'vfabric-hyperic-agent': @@ -87,4 +89,4 @@ warning("Unsupported osfamily ${::osfamily}.") } -} \ No newline at end of file +} diff --git a/templates/hyperic-hqee-agent.init.redhat.erb b/templates/hyperic-hqee-agent.init.redhat.erb index bdbc91b..7889cfd 100644 --- a/templates/hyperic-hqee-agent.init.redhat.erb +++ b/templates/hyperic-hqee-agent.init.redhat.erb @@ -20,21 +20,23 @@ export JAVA_HOME=<%= @java_home %> AGENT_DIR=/opt/hyperic/hyperic-hqee-agent/bin/hq-agent.sh +AGENT_USER=<%= @agent_user %> + case "$1" in start) printf "Starting the hyperic agent...\n" - $AGENT_DIR start + /bin/su $AGENT_USER $AGENT_DIR start ;; stop) printf "Stopping the hyperic agent...\n" - $AGENT_DIR stop + /bin/su $AGENT_USER $AGENT_DIR stop ;; restart) printf "Restarting the hyperic agent...\n" - $AGENT_DIR restart + /bin/su $AGENT_USER $AGENT_DIR restart ;; status) - $AGENT_DIR status + /bin/su $AGENT_USER $AGENT_DIR status ;; *) echo "Usage: $0 {start|stop|restart|status}" From 7d8a20f64208059aa07c6482e995e6ed3eee0a62 Mon Sep 17 00:00:00 2001 From: Matt MacGillivray Date: Tue, 22 Jul 2014 14:55:16 -0400 Subject: [PATCH 02/12] set agent.properties ownership to $agent_user and $agent_group (configurable) --- manifests/agent.pp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index a0a10c0..23e81f7 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -17,7 +17,8 @@ $java_home = '/usr/lib/jvm/jre', $unix_jdk_package = 'java-1.7.0-openjdk-devel', $vfabric_version = '5.3', - $agent_user = 'root', + $agent_user = 'hyperic', + $agent_group = 'vfabric', ) { if $::osfamily == 'RedHat' or $::operatingsystem == 'amazon' { @@ -63,8 +64,8 @@ file { '/opt/hyperic/hyperic-hqee-agent/conf/agent.properties': ensure => file, replace => false, - owner => hyperic, - group => vfabric, + owner => $agent_user, + group => $agent_group, mode => '0644', content => template("${module_name}/agent.properties.erb"), } From 4b146ee784f5bef57cc7972950b2ae2785c63143 Mon Sep 17 00:00:00 2001 From: Matt MacGillivray Date: Tue, 22 Jul 2014 15:13:41 -0400 Subject: [PATCH 03/12] ensure permissions are set properly for hyperic-agent install --- manifests/agent.pp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/manifests/agent.pp b/manifests/agent.pp index 23e81f7..691d5ba 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -70,6 +70,13 @@ content => template("${module_name}/agent.properties.erb"), } + # ensure permissions are correct + exec { "set_permissions": + command => "/bin/chown -R ${agent_user}:${agent_group} /opt/hyperic", + require => [ File["/opt/hyperic/hyperic-hqee-agent/conf/agent.properties"], + Package["vfabric-hyperic-agent"] ] + } + service { 'hyperic-hqee-agent': ensure => running, } From cc0f07858fd67e1e7ec4293b99f8532f2da7710a Mon Sep 17 00:00:00 2001 From: Matt MacGillivray Date: Tue, 22 Jul 2014 15:17:34 -0400 Subject: [PATCH 04/12] start the service AFTER the permissions are fixed. --- manifests/agent.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/agent.pp b/manifests/agent.pp index 691d5ba..383905f 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -79,6 +79,7 @@ service { 'hyperic-hqee-agent': ensure => running, + require => Exec["set_permissions"] } #Relationships From f01a3209e6af6ed32d8dfed537363ae3249ffdb2 Mon Sep 17 00:00:00 2001 From: Matt MacGillivray Date: Tue, 22 Jul 2014 16:32:56 -0400 Subject: [PATCH 05/12] bug - hqserver port (camPort) and agent port (agentPort) were set to the same puppet variable, @setup_port. Split out into @setup_camport and @setup_agentport. renamed associated variables to match. --- manifests/agent.pp | 10 +++++----- templates/agent.properties.erb | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index 383905f..4f4fa00 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -3,15 +3,15 @@ # class hyperic::agent ( $use_vmware_repo = false, - $setup_server = 'localhost', - $setup_port = '7080' , - $setup_sslport = '7443', + $setup_camip = 'localhost', + $setup_camport = '7080' , + $setup_camsslport = '7443', $setup_login = 'hqadmin', $setup_password = 'hqadmin', $setup_unidirectional = 'No', $setup_secure = 'Yes', - $setup_ip = '*default*', - $setup_port = '*default*', + $setup_agentip = '*default*', + $setup_agentport = '*default*', $setup_resetuptoken = 'no', $setup_unverifiedcerts = 'yes', $java_home = '/usr/lib/jvm/jre', diff --git a/templates/agent.properties.erb b/templates/agent.properties.erb index 6112718..2f7de92 100644 --- a/templates/agent.properties.erb +++ b/templates/agent.properties.erb @@ -69,15 +69,15 @@ ## If the value that should be used is the default when interactive ## setup is done, use the string *default* as the value for the option -agent.setup.camIP=<%= @setup_server %> -agent.setup.camPort=<%= @setup_port %> -agent.setup.camSSLPort=<%= @setup_sslport %> +agent.setup.camIP=<%= @setup_camserver %> +agent.setup.camPort=<%= @setup_camport %> +agent.setup.camSSLPort=<%= @setup_camsslport %> agent.setup.camLogin=<%= @setup_login %> agent.setup.camPword=<%= @setup_password %> agent.setup.unidirectional=<%= @setup_unidirectional %> agent.setup.camSecure=<%= @setup_secure %> -agent.setup.agentIP=<%= @setup_ip %> -agent.setup.agentPort=<%= @setup_port %> +agent.setup.agentIP=<%= @setup_agentip %> +agent.setup.agentPort=<%= @setup_agentport %> agent.setup.resetupTokens=<%= @setup_resetuptokens %> agent.setup.acceptUnverifiedCertificate=<%= @setup_unverifiedcerts %> @@ -209,4 +209,4 @@ hq.plugins.configmon.maxdiff=5120 ## define vsphere plugin thread size (default is 1) -scheduleThread.poolsize.vsphere=2 \ No newline at end of file +scheduleThread.poolsize.vsphere=2 From 152c93a98c8b6218545ac38ed6b977c0cb929f4a Mon Sep 17 00:00:00 2001 From: Matt MacGillivray Date: Thu, 24 Jul 2014 11:15:57 -0400 Subject: [PATCH 06/12] bug - setup_resetuptoken missing 's' -> setup_resetuptokens bug - template using wrong variable, changed setup_camserver -> setup_campip --- manifests/agent.pp | 2 +- templates/agent.properties.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index 4f4fa00..4b9f93f 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -12,7 +12,7 @@ $setup_secure = 'Yes', $setup_agentip = '*default*', $setup_agentport = '*default*', - $setup_resetuptoken = 'no', + $setup_resetuptokens = 'no', $setup_unverifiedcerts = 'yes', $java_home = '/usr/lib/jvm/jre', $unix_jdk_package = 'java-1.7.0-openjdk-devel', diff --git a/templates/agent.properties.erb b/templates/agent.properties.erb index 2f7de92..7ddd8bf 100644 --- a/templates/agent.properties.erb +++ b/templates/agent.properties.erb @@ -69,7 +69,7 @@ ## If the value that should be used is the default when interactive ## setup is done, use the string *default* as the value for the option -agent.setup.camIP=<%= @setup_camserver %> +agent.setup.camIP=<%= @setup_camip %> agent.setup.camPort=<%= @setup_camport %> agent.setup.camSSLPort=<%= @setup_camsslport %> agent.setup.camLogin=<%= @setup_login %> From 75ad51c225c1a6d97cb3565c957338de6b605485 Mon Sep 17 00:00:00 2001 From: Matt MacGillivray Date: Thu, 24 Jul 2014 12:24:42 -0400 Subject: [PATCH 07/12] updating so the service is stopped by default. --- manifests/agent.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index 4b9f93f..d00d3f3 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -78,7 +78,7 @@ } service { 'hyperic-hqee-agent': - ensure => running, + ensure => stopped, require => Exec["set_permissions"] } From df13d206e9db9b2f1578802155a639c7fa1f297d Mon Sep 17 00:00:00 2001 From: Matt MacGillivray Date: Fri, 25 Jul 2014 07:35:16 -0400 Subject: [PATCH 08/12] escaping yum variable $basearch --- manifests/agent.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index d00d3f3..b2bbdaa 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -26,13 +26,13 @@ if $use_vmware_repo { $yumrepo_url = $::operatingsystemrelease ? { - /6.?/ => "http://repo.vmware.com/pub/rhel6/vfabric/${vfabric_version}/$basearch", - /5.?/ => "http://repo.vmware.com/pub/rhel5/vfabric/${vfabric_version}/$basearch", + /6.?/ => "http://repo.vmware.com/pub/rhel6/vfabric/${vfabric_version}/\$basearch", + /5.?/ => "http://repo.vmware.com/pub/rhel5/vfabric/${vfabric_version}/\$basearch", } yumrepo { "vfabric-${vfabric_version}": baseurl => $yumrepo_url, - descr => "VMware vFabric ${vfabric_version} - $basearch", + descr => "VMware vFabric ${vfabric_version} - \$basearch", enabled => '1', gpgcheck => '0', } From f5ecc0c49504bf0192264b1b8e7a3fca2758cfbc Mon Sep 17 00:00:00 2001 From: enekogb Date: Wed, 30 Jul 2014 13:55:53 +0200 Subject: [PATCH 09/12] Added $hyperic_package_name param Newer versions of Hyperic have a new package name (vcenter-hyperic-agent instead of vfabric-hyperic-agent) so this change allows a user to choose the package to be installed --- manifests/agent.pp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index b2bbdaa..12f0d1a 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -19,14 +19,15 @@ $vfabric_version = '5.3', $agent_user = 'hyperic', $agent_group = 'vfabric', + $hyperic_package_name = 'vfabric-hyperic-agent', # Change to vcenter-hyperic-agent in newer versions ) { if $::osfamily == 'RedHat' or $::operatingsystem == 'amazon' { if $use_vmware_repo { - $yumrepo_url = $::operatingsystemrelease ? { - /6.?/ => "http://repo.vmware.com/pub/rhel6/vfabric/${vfabric_version}/\$basearch", + $yumrepo_url = $::operatingsystemrelease ?vfabric/$ { + /6.?/ => "http://repo.vmware.com/pub/rhel6/{vfabric_version}/\$basearch", /5.?/ => "http://repo.vmware.com/pub/rhel5/vfabric/${vfabric_version}/\$basearch", } @@ -37,10 +38,10 @@ gpgcheck => '0', } - Yumrepo["vfabric-${vfabric_version}"] -> Package['vfabric-hyperic-agent'] + Yumrepo["vfabric-${vfabric_version}"] -> Package[$hyperic_package_name] } - package { 'vfabric-hyperic-agent': + package { $hyperic_package_name: ensure => installed, } @@ -83,9 +84,9 @@ } #Relationships - Package[$unix_jdk_package] -> Package['vfabric-hyperic-agent'] - Package['vfabric-hyperic-agent'] -> File['/etc/init.d/hyperic-hqee-agent'] - Package['vfabric-hyperic-agent'] ~> Exec['delete_initial_properties_file'] + Package[$unix_jdk_package] -> Package[$hyperic_package_name] + Package[$hyperic_package_name] -> File['/etc/init.d/hyperic-hqee-agent'] + Package[$hyperic_package_name] ~> Exec['delete_initial_properties_file'] Exec['delete_initial_properties_file'] -> File['/opt/hyperic/hyperic-hqee-agent/conf/agent.properties'] File['/etc/init.d/hyperic-hqee-agent'] ~> Service['hyperic-hqee-agent'] File['/opt/hyperic/hyperic-hqee-agent/conf/agent.properties'] ~> Service['hyperic-hqee-agent'] From e2468331b87be14abf990b6a1219a6c14ddff1fb Mon Sep 17 00:00:00 2001 From: enekogb Date: Wed, 30 Jul 2014 14:22:16 +0200 Subject: [PATCH 10/12] Update agent.pp repo_url fixed (was broken in previous commit) --- manifests/agent.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index 12f0d1a..4434e4c 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -26,11 +26,11 @@ if $use_vmware_repo { - $yumrepo_url = $::operatingsystemrelease ?vfabric/$ { - /6.?/ => "http://repo.vmware.com/pub/rhel6/{vfabric_version}/\$basearch", + $yumrepo_url = $::operatingsystemrelease ? { + /6.?/ => "http://repo.vmware.com/pub/rhel6/vfabric/${vfabric_version}/\$basearch", /5.?/ => "http://repo.vmware.com/pub/rhel5/vfabric/${vfabric_version}/\$basearch", } - + yumrepo { "vfabric-${vfabric_version}": baseurl => $yumrepo_url, descr => "VMware vFabric ${vfabric_version} - \$basearch", From 04301c1005b5fdff55a0c632e09efd02d45e66bf Mon Sep 17 00:00:00 2001 From: enekogb Date: Wed, 30 Jul 2014 14:24:55 +0200 Subject: [PATCH 11/12] Update agent.pp Fixed dependency on package in Exec["set_permissions"] --- manifests/agent.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index 4434e4c..3dddb0b 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -75,7 +75,7 @@ exec { "set_permissions": command => "/bin/chown -R ${agent_user}:${agent_group} /opt/hyperic", require => [ File["/opt/hyperic/hyperic-hqee-agent/conf/agent.properties"], - Package["vfabric-hyperic-agent"] ] + Package[$hyperic_package_name] ] } service { 'hyperic-hqee-agent': From d45f87c782ede111351de30ad72ef9ef1bba654f Mon Sep 17 00:00:00 2001 From: enekogb Date: Fri, 1 Aug 2014 10:36:36 +0200 Subject: [PATCH 12/12] Update agent.pp Changed 'delete_initial_properties_file' condition so it's executed when agent.properties is not managed by puppet, looking for 'puppet' word inside it. When hyperic package is removed in RHEL, 'agent.scu' file isn't removed, so previous code doesn't regenerate agent.properties with the correct values. --- manifests/agent.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/agent.pp b/manifests/agent.pp index 3dddb0b..0bf4b9e 100644 --- a/manifests/agent.pp +++ b/manifests/agent.pp @@ -49,7 +49,7 @@ exec { 'delete_initial_properties_file': command => '/bin/rm -f /opt/hyperic/hyperic-hqee-agent/conf/agent.properties', refreshonly => true, - onlyif => '/usr/bin/test ! -f /opt/hyperic/hyperic-hqee-agent/conf/agent.scu', + unless => "/bin/grep -i 'puppet' /opt/hyperic/hyperic-hqee-agent/conf/agent.properties", } ensure_packages([$unix_jdk_package])