summaryrefslogtreecommitdiffstats
path: root/bin/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-10-05 00:07:38 -0500
committerLuke Kanies <luke@madstop.com>2007-10-05 00:07:38 -0500
commit0e336bf62b818aaa31fcc323ab5d31e5eb92eb46 (patch)
tree2f29d3e668aad2cade6059c74cbba60d60873561 /bin/puppet
parent1fa591287a4ab921cec628aa0c5bf58d61fbdef2 (diff)
downloadpuppet-0e336bf62b818aaa31fcc323ab5d31e5eb92eb46.tar.gz
puppet-0e336bf62b818aaa31fcc323ab5d31e5eb92eb46.tar.xz
puppet-0e336bf62b818aaa31fcc323ab5d31e5eb92eb46.zip
This commit is focused on getting the 'puppet' executable
to work. As a result, it involves a lot of integration-level testing, and a lot of small design changes to make the code actually work. In particular, indirections can now have default termini, so that configurations and facts default to their code terminus Also, I've removed the ability to manually control whether ast nodes are used. I might need to add it back in later, but if so it will be in the form of a global setting, rather than the previous system of passing it through 10 different classes. Instead, the parser detects whether there are AST nodes defined and requires them if so or ignores them if not. About 75 tests are still failing in the main set of tests, but it's going to be a long slog to get them working -- there are significant design issues around them, as most of the failures are a result of tests trying to emulate both the client and server sides of a connection, which normally would have different fact termini but in this case must have the same terminus just because they're in the same process and are global. The next step, then, is to figure that process out, thus finding a way to make this all work.
Diffstat (limited to 'bin/puppet')
-rwxr-xr-xbin/puppet79
1 files changed, 45 insertions, 34 deletions
diff --git a/bin/puppet b/bin/puppet
index a87a07619..a5aa030ac 100755
--- a/bin/puppet
+++ b/bin/puppet
@@ -80,14 +80,16 @@ Puppet.settings.addargs(options)
result = GetoptLong.new(*options)
-debug = false
-verbose = false
-noop = false
-logfile = false
-loadclasses = false
-logset = false
+options = {
+ :debug => false,
+ :verbose => false,
+ :noop => false,
+ :logfile => false,
+ :loadclasses => false,
+ :logset => false,
+ :code => nil
+}
-code = nil
master = {
:Local => true
@@ -107,19 +109,19 @@ begin
exit
end
when "--use-nodes"
- master[:UseNodes] = true
+ options[:UseNodes] = true
when "--verbose"
- verbose = true
+ options[:verbose] = true
when "--debug"
- debug = true
+ options[:debug] = true
when "--execute"
- code = arg
+ options[:code] = arg
when "--loadclasses"
- loadclasses = true
+ options[:loadclasses] = true
when "--logdest"
begin
Puppet::Util::Log.newdestination(arg)
- logset = true
+ options[:logset] = true
rescue => detail
$stderr.puts detail.to_s
end
@@ -139,7 +141,7 @@ if Puppet[:noop]
Puppet[:show_diff] = true
end
-unless logset
+unless options[:logset]
Puppet::Util::Log.newdestination(:console)
end
@@ -148,9 +150,9 @@ server = nil
Puppet.settraps
-if debug
+if options[:debug]
Puppet::Util::Log.level = :debug
-elsif verbose
+elsif options[:verbose]
Puppet::Util::Log.level = :info
end
@@ -162,18 +164,26 @@ end
Puppet.genconfig
Puppet.genmanifest
-if code
- master[:Code] = code
+# Set our code or file to use.
+if options[:code] or ARGV.length == 0
+ Puppet::Node::Configuration.code = options[:code] || STDIN.read
else
- if ARGV.length > 0
- master[:Manifest] = ARGV.shift
- else
- master[:Code] = STDIN.read
- end
+ Puppet[:manifest] = ARGV.shift
end
+# Collect our facts.
+Puppet::Node::Facts.terminus_class = :code
+facts = Puppet::Node::Facts.find("me")
+facts.name = facts.values["hostname"]
+
+# Create our Node
+node = Puppet::Node.new(facts.name)
+
+# Merge in the facts.
+node.merge(facts.values)
+
# Allow users to load the classes that puppetd creates.
-if loadclasses
+if options[:loadclasses]
file = Puppet[:classfile]
if FileTest.exists?(file)
unless FileTest.readable?(file)
@@ -181,20 +191,21 @@ if loadclasses
exit(63)
end
- master[:Classes] = File.read(file).split(/[\s\n]+/)
+ node.classes = File.read(file).split(/[\s\n]+/)
end
end
+# Compile and apply the configuration
+Puppet::Node::Configuration.terminus_class = :code
+
begin
- server = Puppet::Network::Handler.master.new(master)
- client = Puppet::Network::Client.master.new(
- :Master => server,
- :Cache => false
- )
- if Puppet[:parseonly]
- exit(0)
- end
- config = client.getconfig
+ # Compile our configuration
+ config = Puppet::Node::Configuration.find(node)
+
+ # Translate it to a RAL configuration
+ config = config.extract_to_transportable.to_configuration
+
+ # And apply it
config.apply
rescue => detail
if Puppet[:trace]