diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-01-30 19:18:32 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-01-30 19:18:32 +0000 |
commit | 8d90e5672e1f516310cd98077e8932b79c4970cf (patch) | |
tree | 7066857c39ef49147fb6620f61827f47148bf1ac | |
parent | 8821300528e0e0ba4c4f0055911d263ae0b0133b (diff) | |
download | puppet-8d90e5672e1f516310cd98077e8932b79c4970cf.tar.gz puppet-8d90e5672e1f516310cd98077e8932b79c4970cf.tar.xz puppet-8d90e5672e1f516310cd98077e8932b79c4970cf.zip |
Puppet can now read files on stdin. This means you can put "#!/usr/bin/env puppet" in the first line of a puppet manifest and then execute the manifest normally. Yay!
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2130 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-x | bin/puppet | 6 | ||||
-rwxr-xr-x | test/executables/puppetbin.rb | 22 |
2 files changed, 27 insertions, 1 deletions
diff --git a/bin/puppet b/bin/puppet index bb8160e7a..8ded2304c 100755 --- a/bin/puppet +++ b/bin/puppet @@ -158,7 +158,11 @@ Puppet.genmanifest if code master[:Code] = code else - master[:Manifest] = ARGV.shift + if ARGV.length > 0 + master[:Manifest] = ARGV.shift + else + master[:Code] = STDIN.read + end end # Allow users to load the classes that puppetd creates. diff --git a/test/executables/puppetbin.rb b/test/executables/puppetbin.rb index 4fde6ba59..1752848a8 100755 --- a/test/executables/puppetbin.rb +++ b/test/executables/puppetbin.rb @@ -64,6 +64,28 @@ class TestPuppetBin < Test::Unit::TestCase assert(FileTest.exists?(path), "Failed to create config'ed file") end + + def test_stdin_execution + path = tempfile() + manifest = tempfile() + env = %x{which env}.chomp + if env == "" + Puppet.info "cannot find env; cannot test stdin_execution" + return + end + File.open(manifest, "w") do |f| + f.puts "#!#{env} puppet + file { '#{path}': ensure => file }" + end + File.chmod(0755, manifest) + + assert_nothing_raised { + out = %x{#{manifest} 2>&1} + } + assert($? == 0, "manifest exited with code %s" % $?.to_i) + + assert(FileTest.exists?(path), "Failed to create config'ed file") + end end # $Id$ |