Sha256: 0a027f5712858a6248bf012ca9de5d091e808e62ad56e8f7819391206bea7be2

Contents?: true

Size: 1.5 KB

Versions: 50

Compression:

Stored size: 1.5 KB

Contents

require 'puppet/face'
require 'puppet/parser'

Puppet::Face.define(:parser, '0.0.1') do
  copyright "Puppet Labs", 2011
  license   "Apache 2 license; see COPYING"

  summary "Interact directly with the parser."

  action :validate do
    summary "Validate the syntax of one or more Puppet manifests."
    arguments "[<manifest>] [<manifest> ...]"
    returns "Nothing, or the first syntax error encountered."
    description <<-'EOT'
      This action validates Puppet DSL syntax without compiling a catalog or
      syncing any resources. If no manifest files are provided, it will
      validate the default site manifest.
    EOT
    examples <<-'EOT'
      Validate the default site manifest at /etc/puppet/manifests/site.pp:

      $ puppet parser validate

      Validate two arbitrary manifest files:

      $ puppet parser validate init.pp vhost.pp

      Validate from STDIN:

      $ cat init.pp | puppet parser validate
    EOT
    when_invoked do |*args|
      args.pop
      files = args
      if files.empty?
        if not STDIN.tty?
          Puppet[:code] = STDIN.read
          Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types.clear
        else
           files << Puppet[:manifest]
           Puppet.notice "No manifest specified. Validating the default manifest #{Puppet[:manifest]}"
        end
      end
      files.each do |file|
        Puppet[:manifest] = file
        Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types.clear
      end
      nil
    end
  end
end

Version data entries

50 entries across 50 versions & 3 rubygems

Version Path
puppet-parse-0.0.2 lib/vendor/puppet/face/parser.rb
puppet-2.7.20 lib/puppet/face/parser.rb
puppet-2.7.20.rc1 lib/puppet/face/parser.rb
puppet-3.0.1 lib/puppet/face/parser.rb
puppet-3.0.1.rc1 lib/puppet/face/parser.rb
puppet-3.0.0 lib/puppet/face/parser.rb
puppet-3.0.0.rc8 lib/puppet/face/parser.rb
puppet-3.0.0.rc7 lib/puppet/face/parser.rb
puppet-3.0.0.rc5 lib/puppet/face/parser.rb
puppet-3.0.0.rc4 lib/puppet/face/parser.rb