From e6a9e094a8b2df1271c39f08472b788fe3e3d0c8 Mon Sep 17 00:00:00 2001 From: Luca Filipozzi Date: Wed, 16 May 2012 18:11:19 +0000 Subject: [PATCH] expand hiera data and add cluster info to motd --- hieradata/clusters/ganeti2.debian.org.yaml | 4 ++++ modules/debian-org/lib/facter/cluster.rb | 2 +- modules/motd/templates/motd.erb | 14 ++++++++++++++ modules/puppetmaster/files/hiera.yaml | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 hieradata/clusters/ganeti2.debian.org.yaml diff --git a/hieradata/clusters/ganeti2.debian.org.yaml b/hieradata/clusters/ganeti2.debian.org.yaml new file mode 100644 index 000000000..778939a86 --- /dev/null +++ b/hieradata/clusters/ganeti2.debian.org.yaml @@ -0,0 +1,4 @@ +--- +nodes: + - 'pasquini.debian.org' + - 'tristano.debian.org' diff --git a/modules/debian-org/lib/facter/cluster.rb b/modules/debian-org/lib/facter/cluster.rb index 6b083a401..3588868c9 100644 --- a/modules/debian-org/lib/facter/cluster.rb +++ b/modules/debian-org/lib/facter/cluster.rb @@ -1,6 +1,6 @@ Facter.add('cluster') do setcode do - if system('/usr/sbin/gnt-cluster getmaster') + if system('/usr/sbin/gnt-cluster getmaster >/dev/null') require 'json' config = '/var/lib/ganeti/config.data' if FileTest.exist?(config) diff --git a/modules/motd/templates/motd.erb b/modules/motd/templates/motd.erb index 6beeadd3b..8844871c7 100644 --- a/modules/motd/templates/motd.erb +++ b/modules/motd/templates/motd.erb @@ -100,9 +100,23 @@ unless vms.empty? end +if hiera('cluster') + purp += "\nganeti cluster: " + hiera('cluster') + " contains these nodes:\n" + hiera_array('nodes').each do |node| + purp += "\t" + node + if node.eql?(fqdn) + purp += " (this system)" + end + purp += "\n" + end + purp += "\n" +end + + if scope.lookupvar('site::nodeinfo').has_key?('footer') purp += "\n" + wrap(scope.lookupvar('site::nodeinfo')['footer']) + "\n" end + purp -%> diff --git a/modules/puppetmaster/files/hiera.yaml b/modules/puppetmaster/files/hiera.yaml index 98411f6c1..54fab8b91 100644 --- a/modules/puppetmaster/files/hiera.yaml +++ b/modules/puppetmaster/files/hiera.yaml @@ -1,6 +1,7 @@ --- :hierarchy: - %{hoster} + - clusters/%{cluster} - common :backends: - yaml -- 2.20.1