From 02d0aa1ecbada16b8e122928c6a8a59ba872c677 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 25 Oct 2012 14:25:39 -0700 Subject: [PATCH] Make cacti_device a define. cacti_device was a class of which only one could be instantiated. Make it a define so that many cacti_devices can be installed. While we are fixing this correct the puppet lint warnings and errors for cacti. Change-Id: Ic730f542d15ee05884e6e2eae0df09f36a55730e Reviewed-on: https://review.openstack.org/14853 Reviewed-by: Paul Belanger Approved: James E. Blair Reviewed-by: James E. Blair Tested-by: Jenkins --- modules/openstack_project/manifests/cacti.pp | 106 +++++++++--------- .../manifests/cacti_device.pp | 9 ++ 2 files changed, 63 insertions(+), 52 deletions(-) create mode 100644 modules/openstack_project/manifests/cacti_device.pp diff --git a/modules/openstack_project/manifests/cacti.pp b/modules/openstack_project/manifests/cacti.pp index 375e6c7b66..ce063e5505 100644 --- a/modules/openstack_project/manifests/cacti.pp +++ b/modules/openstack_project/manifests/cacti.pp @@ -1,74 +1,76 @@ +# Class to configure cacti on a node. +# Takes a list of sysadmin email addresses as a parameter. Exim will be +# configured to email cron spam and other alerts to this list of admins. class openstack_project::cacti ( $sysadmins = [] ) { class { 'openstack_project::server': iptables_public_tcp_ports => [80, 443], - sysadmins => $sysadmins + sysadmins => $sysadmins, } include apache package { 'cacti': - ensure => present + ensure => present, } - file { "/usr/local/share/cacti/resource/snmp_queries": + file { '/usr/local/share/cacti/resource/snmp_queries': ensure => directory, - owner => "root", - } - - file { "/usr/local/share/cacti/resource/snmp_queries/net-snmp_devio.xml": - source => "puppet:///modules/openstack_project/cacti/net-snmp_devio.xml", - mode => 644, - owner => "root", - group => "root", - require => File["/usr/local/share/cacti/resource/snmp_queries"], + owner => 'root', } - file { "/var/lib/cacti/linux_host.xml": - source => "puppet:///modules/openstack_project/cacti/linux_host.xml", - mode => 644, - owner => "root", - group => "root", - require => File["/usr/local/share/cacti/resource/snmp_queries/net-snmp_devio.xml"], + file { '/usr/local/share/cacti/resource/snmp_queries/net-snmp_devio.xml': + ensure => present, + source => 'puppet:///modules/openstack_project/cacti/net-snmp_devio.xml', + mode => '0644', + owner => 'root', + group => 'root', + require => File['/usr/local/share/cacti/resource/snmp_queries'], } - file { "/usr/local/bin/create_graphs.sh": - source => "puppet:///modules/openstack_project/cacti/create_graphs.sh", - mode => 744, - owner => "root", - group => "root", + file { '/var/lib/cacti/linux_host.xml': + ensure => present, + source => 'puppet:///modules/openstack_project/cacti/linux_host.xml', + mode => '0644', + owner => 'root', + group => 'root', + require => File[ + '/usr/local/share/cacti/resource/snmp_queries/net-snmp_devio.xml' + ], } - exec { "cacti_import_xml": - command => "/usr/bin/php -q /usr/share/cacti/cli/import_template.php \ - --filename=/var/lib/cacti/linux_host.xml \ - --with-template-rras", - cwd => "/usr/share/cacti/cli", - require => File["/var/lib/cacti/linux_host.xml"], + file { '/usr/local/bin/create_graphs.sh': + ensure => present, + source => 'puppet:///modules/openstack_project/cacti/create_graphs.sh', + mode => '0744', + owner => 'root', + group => 'root', } - class {'cacti_device': hostname=> 'community.openstack.org'} - class {'cacti_device': hostname=> 'eavesdrop.openstack.org'} - class {'cacti_device': hostname=> 'etherpad.openstack.org'} - class {'cacti_device': hostname=> 'jenkins-dev.openstack.org'} - class {'cacti_device': hostname=> 'jenkins.openstack.org'} - class {'cacti_device': hostname=> 'lists.openstack.org'} - class {'cacti_device': hostname=> 'paste.openstack.org'} - class {'cacti_device': hostname=> 'planet.openstack.org'} - class {'cacti_device': hostname=> 'pypi.openstack.org'} - class {'cacti_device': hostname=> 'review-dev.openstack.org'} - class {'cacti_device': hostname=> 'review.openstack.org'} - class {'cacti_device': hostname=> 'static.openstack.org'} - class {'cacti_device': hostname=> 'wiki.openstack.org'} + exec { 'cacti_import_xml': + command => '/usr/bin/php -q /usr/share/cacti/cli/import_template.php \ + --filename=/var/lib/cacti/linux_host.xml \ + --with-template-rras', + cwd => 'usr/share/cacti/cli', + require => File['/var/lib/cacti/linux_host.xml'], + } + + $cacti_hosts = [ + 'community.openstack.org', + 'eavesdrop.openstack.org', + 'etherpad.openstack.org', + 'jenkins.openstack.org', + 'jenkins-dev.openstack.org', + 'lists.openstack.org', + 'paste.openstack.org', + 'planet.openstack.org', + 'pypi.openstack.org', + 'review.openstack.org', + 'review-dev.openstack.org', + 'static.openstack.org', + 'wiki.openstack.org', + ] + + openstack_project::cacti_device { $cacti_hosts: } } - -class cacti_device( - $hostname -){ - exec { "cacti_create_$hostname": - command => "/usr/local/bin/create_graphs.sh $hostname", - require => Exec["cacti_import_xml"] - } -} - diff --git a/modules/openstack_project/manifests/cacti_device.pp b/modules/openstack_project/manifests/cacti_device.pp new file mode 100644 index 0000000000..9bc980cf73 --- /dev/null +++ b/modules/openstack_project/manifests/cacti_device.pp @@ -0,0 +1,9 @@ +# Define that adds a host to a cacti installation. +# Takes the fqdn of the host as the namevar for this define. +define openstack_project::cacti_device() +{ + exec { "cacti_create_${name}": + command => "/usr/local/bin/create_graphs.sh ${name}", + require => Exec['cacti_import_xml'] + } +}