Matanya has uploaded a new change for review. https://gerrit.wikimedia.org/r/108498
Change subject: torrus: move into a module ...................................................................... torrus: move into a module Change-Id: I984ce4922c1eeea855a51ba1389b423efc9c794f --- M manifests/site.pp R modules/torrus/files/default-dir-modified.html R modules/torrus/files/html-incblocks-modified.txt R modules/torrus/files/overview-dir.html R modules/torrus/files/schema-override.pl R modules/torrus/files/torrus-discovery R modules/torrus/files/wikimedia.css R modules/torrus/files/xmlconfig/aggregates.xml R modules/torrus/files/xmlconfig/facilities_aggregates.xml R modules/torrus/files/xmlconfig/power.xml R modules/torrus/files/xmlconfig/servertech-mib.xml R modules/torrus/files/xmlconfig/squid-mib.xml R modules/torrus/files/xmlconfig/varnish-mib.xml A modules/torrus/manifests/config.pp A modules/torrus/manifests/ddxfile.pp A modules/torrus/manifests/discovery.pp A modules/torrus/manifests/init.pp A modules/torrus/manifests/web.pp A modules/torrus/manifests/xml-generation.pp A modules/torrus/manifests/xmlconfig.pp R modules/torrus/templates/cdn-aggregates.xml.erb R modules/torrus/templates/generic.ddx.erb R modules/torrus/templates/site-global.xml.erb R modules/torrus/templates/squid.xml.erb R modules/torrus/templates/varnish.xml.erb 25 files changed, 188 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/98/108498/1 diff --git a/manifests/site.pp b/manifests/site.pp index 5322c73..021a85f 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -1113,9 +1113,7 @@ include standard, webserver::apache, - misc::torrus, - misc::torrus::web, - misc::torrus::xml-generation::cdn, + torrus, ganglia::collector include passwords::network diff --git a/files/torrus/templates/default-dir-modified.html b/modules/torrus/files/default-dir-modified.html similarity index 100% rename from files/torrus/templates/default-dir-modified.html rename to modules/torrus/files/default-dir-modified.html diff --git a/files/torrus/templates/html-incblocks-modified.txt b/modules/torrus/files/html-incblocks-modified.txt similarity index 100% rename from files/torrus/templates/html-incblocks-modified.txt rename to modules/torrus/files/html-incblocks-modified.txt diff --git a/files/torrus/templates/overview-dir.html b/modules/torrus/files/overview-dir.html similarity index 100% rename from files/torrus/templates/overview-dir.html rename to modules/torrus/files/overview-dir.html diff --git a/files/torrus/conf/schema-override.pl b/modules/torrus/files/schema-override.pl similarity index 100% rename from files/torrus/conf/schema-override.pl rename to modules/torrus/files/schema-override.pl diff --git a/files/torrus/torrus-discovery b/modules/torrus/files/torrus-discovery similarity index 100% rename from files/torrus/torrus-discovery rename to modules/torrus/files/torrus-discovery diff --git a/files/torrus/wikimedia.css b/modules/torrus/files/wikimedia.css similarity index 100% rename from files/torrus/wikimedia.css rename to modules/torrus/files/wikimedia.css diff --git a/files/torrus/xmlconfig/aggregates.xml b/modules/torrus/files/xmlconfig/aggregates.xml similarity index 100% rename from files/torrus/xmlconfig/aggregates.xml rename to modules/torrus/files/xmlconfig/aggregates.xml diff --git a/files/torrus/xmlconfig/facilities_aggregates.xml b/modules/torrus/files/xmlconfig/facilities_aggregates.xml similarity index 100% rename from files/torrus/xmlconfig/facilities_aggregates.xml rename to modules/torrus/files/xmlconfig/facilities_aggregates.xml diff --git a/files/torrus/xmlconfig/power.xml b/modules/torrus/files/xmlconfig/power.xml similarity index 100% rename from files/torrus/xmlconfig/power.xml rename to modules/torrus/files/xmlconfig/power.xml diff --git a/files/torrus/xmlconfig/servertech-mib.xml b/modules/torrus/files/xmlconfig/servertech-mib.xml similarity index 100% rename from files/torrus/xmlconfig/servertech-mib.xml rename to modules/torrus/files/xmlconfig/servertech-mib.xml diff --git a/files/torrus/xmlconfig/squid-mib.xml b/modules/torrus/files/xmlconfig/squid-mib.xml similarity index 100% rename from files/torrus/xmlconfig/squid-mib.xml rename to modules/torrus/files/xmlconfig/squid-mib.xml diff --git a/files/torrus/xmlconfig/varnish-mib.xml b/modules/torrus/files/xmlconfig/varnish-mib.xml similarity index 100% rename from files/torrus/xmlconfig/varnish-mib.xml rename to modules/torrus/files/xmlconfig/varnish-mib.xml diff --git a/modules/torrus/manifests/config.pp b/modules/torrus/manifests/config.pp new file mode 100644 index 0000000..aad134b --- /dev/null +++ b/modules/torrus/manifests/config.pp @@ -0,0 +1,45 @@ +class torrus::config { + + file { '/etc/torrus/conf/': + source => 'puppet:///modules/torrus/conf/', + owner => 'root', + group => 'root', + mode => '0444', + recurse => remote, + } + + file { '/etc/torrus/templates/': + source => 'puppet:///modules/torrus/templates/', + owner => 'root', + group => 'root', + mode => '0444', + recurse => remote, + } + + file { '/usr/share/torrus/sup/webplain/wikimedia.css': + owner => 'root', + group => 'root', + mode => '0444', + source => 'puppet:///modules/torrus/wikimedia.css', + } + + exec { 'torrus clearcache': + command => '/usr/sbin/torrus clearcache', + logoutput => true, + refreshonly => true, + before => Exec["torrus compile"], + } + + exec { 'torrus compile': + command => '/usr/sbin/torrus compile --all', + logoutput => true, + refreshonly => true, + } + + service { 'torrus-common': + ensure => running, + require => Exec['torrus compile'], + subscribe => File[ ['/etc/torrus/conf/', '/etc/torrus/templates/']], + hasrestart => false, + } +} diff --git a/modules/torrus/manifests/ddxfile.pp b/modules/torrus/manifests/ddxfile.pp new file mode 100644 index 0000000..e6239aa --- /dev/null +++ b/modules/torrus/manifests/ddxfile.pp @@ -0,0 +1,27 @@ +# Definition: misc::torrus::discovery +# +# This definition generates a torrus discovery DDX file, which Torrus +# will use to compile its XML config files from SNMP +# +# Parameters: +# - $subtree: the Torrus subtree path used in the XML config file +# - $domain: The domain name to use for SNMP host names +# - $snmp_community: The SNMP community needed to query +# - $hosts: A list of hosts +define torrus::ddxfile( + $subtree, + $domain = '', + $snmp_community = 'public', + $hosts = [] +) { + + file { "/etc/torrus/discovery/${title}.ddx": + require => File['/etc/torrus/discovery'], + content => template('torrus/generic.ddx.erb'), + owner => 'root', + group => 'root', + mode => '0444', + before => Exec['torrus-discovery'], + notify => Exec['torrus-discovery'], + } +} diff --git a/modules/torrus/manifests/discovery.pp b/modules/torrus/manifests/discovery.pp new file mode 100644 index 0000000..e5628d8 --- /dev/null +++ b/modules/torrus/manifests/discovery.pp @@ -0,0 +1,25 @@ +class torrus::discovery { + + file { '/etc/torrus/discovery': + ensure => directory, + owner => 'root', + group => 'root', + mode => '0750', + } + + file { '/etc/cron.daily/torrus-discovery': + source => 'puppet:///modules/torrus/torrus-discovery', + owner => 'root', + group => 'root', + mode => '0550' + } + + exec { 'torrus-discovery': + require => File['/etc/cron.daily/torrus-discovery'], + command => '/etc/cron.daily/torrus-discovery', + timeout => 1800, + refreshonly => true, + before => Exec['torrus compile'], + } +} + diff --git a/modules/torrus/manifests/init.pp b/modules/torrus/manifests/init.pp new file mode 100644 index 0000000..5bb6840 --- /dev/null +++ b/modules/torrus/manifests/init.pp @@ -0,0 +1,15 @@ +class torrus { + + include torrus::config, + torrus::ddxfile, + torrus::discovery, + torrus::web, + torrus::xml-generation, + torrus::xmlconfig + + system::role { 'torrus': description => 'Torrus' } + + package { 'torrus-common': + ensure => latest, + } +} diff --git a/modules/torrus/manifests/web.pp b/modules/torrus/manifests/web.pp new file mode 100644 index 0000000..9bd098b --- /dev/null +++ b/modules/torrus/manifests/web.pp @@ -0,0 +1,15 @@ +class torrus::web { + + package { 'torrus-apache2': + ensure => latest, + before => Class['webserver::apache::service'], + } + + @webserver::apache::module { ['perl', 'rewrite']: } + @webserver::apache::site { 'torrus.wikimedia.org': + require => Webserver::Apache::Module[['perl', 'rewrite']], + docroot => '/var/www', + custom => ['RedirectMatch ^/$ /torrus'], + includes => ['/etc/torrus/torrus-apache2.conf'] + } +} diff --git a/modules/torrus/manifests/xml-generation.pp b/modules/torrus/manifests/xml-generation.pp new file mode 100644 index 0000000..4160c4a --- /dev/null +++ b/modules/torrus/manifests/xml-generation.pp @@ -0,0 +1,41 @@ +class torrus::xml-generation { +# Class: misc::torrus::xml-generation +# +# This class automatically generates XML files for +# Squid and Varnish servers +# +# Uses role/cache/cache.pp + require role::cache::configuration + include xmlconfig, + discovery + + file { '/etc/torrus/xmlconfig/varnish.xml': + owner => 'root', + group => 'root', + mode => '0444', + notify => Exec['torrus compile --tree=CDN'], + content => template('torrus/varnish.xml.erb'), + } + + file { '/etc/torrus/xmlconfig/squid.xml': + owner => 'root', + group => 'root', + mode => '0444', + notify => Exec['torrus compile --tree=CDN'], + content => template('torrus/squid.xml.erb'), + } + + file { '/etc/torrus/xmlconfig/cdn-aggregates.xml': + owner => 'root', + group => 'root', + mode => '0444', + notify => Exec['torrus compile --tree=CDN'], + content => template('torrus/cdn-aggregates.xml.erb'), + } + + exec { 'torrus compile --tree=CDN': + path => '/bin:/sbin:/usr/bin:/usr/sbin', + logoutput => true, + refreshonly => true; + } +} diff --git a/modules/torrus/manifests/xmlconfig.pp b/modules/torrus/manifests/xmlconfig.pp new file mode 100644 index 0000000..d8a5d5f --- /dev/null +++ b/modules/torrus/manifests/xmlconfig.pp @@ -0,0 +1,19 @@ +class torrus::xmlconfig { + include passwords::network + + file { '/etc/torrus/xmlconfig/': + source => 'puppet:///modules/torrus/xmlconfig/', + owner => 'root', + group => 'root', + mode => '0444', + recurse => remote, + } + + file { '/etc/torrus/xmlconfig/site-global.xml': + owner => 'root', + group => 'root', + mode => '0444', + content => template('torrus/site-global.xml.erb'), + } +} + diff --git a/templates/torrus/cdn-aggregates.xml.erb b/modules/torrus/templates/cdn-aggregates.xml.erb similarity index 100% rename from templates/torrus/cdn-aggregates.xml.erb rename to modules/torrus/templates/cdn-aggregates.xml.erb diff --git a/templates/torrus/generic.ddx.erb b/modules/torrus/templates/generic.ddx.erb similarity index 100% rename from templates/torrus/generic.ddx.erb rename to modules/torrus/templates/generic.ddx.erb diff --git a/templates/torrus/site-global.xml.erb b/modules/torrus/templates/site-global.xml.erb similarity index 100% rename from templates/torrus/site-global.xml.erb rename to modules/torrus/templates/site-global.xml.erb diff --git a/templates/torrus/squid.xml.erb b/modules/torrus/templates/squid.xml.erb similarity index 100% rename from templates/torrus/squid.xml.erb rename to modules/torrus/templates/squid.xml.erb diff --git a/templates/torrus/varnish.xml.erb b/modules/torrus/templates/varnish.xml.erb similarity index 100% rename from templates/torrus/varnish.xml.erb rename to modules/torrus/templates/varnish.xml.erb -- To view, visit https://gerrit.wikimedia.org/r/108498 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I984ce4922c1eeea855a51ba1389b423efc9c794f Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Matanya <mata...@foss.co.il> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits