summaryrefslogtreecommitdiff
path: root/bin/puppet_command
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-04-03 11:22:34 -0700
committerelijah <elijah@riseup.net>2013-04-03 11:22:34 -0700
commit705890760c7153efc987fdf6eab7d5a90cf98158 (patch)
tree6d312310b0cad2b045ca45d4101e9af25ddcdbf8 /bin/puppet_command
parent710e4dd1826f4c98c787108a048fd679cc990d67 (diff)
minor fix to puppet_command (--verbose no longer required, added default --tags)
Diffstat (limited to 'bin/puppet_command')
-rwxr-xr-xbin/puppet_command54
1 files changed, 31 insertions, 23 deletions
diff --git a/bin/puppet_command b/bin/puppet_command
index 672a3699..a6cd5a69 100755
--- a/bin/puppet_command
+++ b/bin/puppet_command
@@ -7,14 +7,31 @@
# (exit codes, lockfile, multiple manifests, etc)
#
-$puppet_bin = '/usr/bin/puppet'
-$puppet_directory = '/srv/leap'
-$puppet_parameters = '--color=false --detailed-exitcodes --libdir=puppet/lib --confdir=puppet'
-$site_manifest = 'puppet/manifests/site.pp'
-$setup_manifest = 'puppet/manifests/setup.pp'
+PUPPET_BIN = '/usr/bin/puppet'
+PUPPET_DIRECTORY = '/srv/leap'
+PUPPET_PARAMETERS = '--color=false --detailed-exitcodes --libdir=puppet/lib --confdir=puppet'
+SITE_MANIFEST = 'puppet/manifests/site.pp'
+SETUP_MANIFEST = 'puppet/manifests/setup.pp'
+DEFAULT_TAGS = 'leap_base,leap_service'
def main
+ process_command_line_arguments
+ with_lockfile do
+ @commands.each do |command|
+ self.send(command)
+ end
+ end
+end
+
+def puts(str)
+ $stdout.puts str
+ $stdout.flush
+end
+
+def process_command_line_arguments
@commands = []
+ @verbosity = 1
+ @tags = DEFAULT_TAGS
loop do
case ARGV[0]
when 'apply' then ARGV.shift; @commands << 'apply'
@@ -27,16 +44,6 @@ def main
end
end
usage("No command given") unless @commands.any?
- with_lockfile do
- @commands.each do |command|
- self.send(command)
- end
- end
-end
-
-def puts(str)
- $stdout.puts str
- $stdout.flush
end
def apply
@@ -47,11 +54,12 @@ def apply
end
def set_hostname
- exit_code = puppet_apply(:manifest => $setup_manifest, :tags => '') do |line|
- # todo: how to suppress this?
- # dnsdomainname: Name or service not known
- # warning: Could not retrieve fact fqdn
- if line !~ /Finished catalog run/ || @verbosity > 2
+ exit_code = puppet_apply(:manifest => SETUP_MANIFEST, :tags => '') do |line|
+ # todo: replace setup.pp with https://github.com/lutter/ruby-augeas
+ # or try this: http://www.puppetcookbook.com/posts/override-a-facter-fact.html
+ if (line !~ /Finished catalog run/ || @verbosity > 2) &&
+ (line !~ /dnsdomainname: Name or service not known/) &&
+ (line !~ /warning: Could not retrieve fact fqdn/)
puts line
end
end
@@ -69,9 +77,9 @@ end
#
def puppet_apply(options={}, &block)
options = {:verbosity => @verbosity, :tags => @tags}.merge(options)
- manifest = options[:manifest] || $site_manifest
- Dir.chdir($puppet_directory) do
- return run("#{$puppet_bin} apply #{custom_parameters(options)} #{$puppet_parameters} #{manifest}", &block)
+ manifest = options[:manifest] || SITE_MANIFEST
+ Dir.chdir(PUPPET_DIRECTORY) do
+ return run("#{PUPPET_BIN} apply #{custom_parameters(options)} #{PUPPET_PARAMETERS} #{manifest}", &block)
end
end