Created
October 29, 2011 10:42
-
-
Save masterzen/1324327 to your computer and use it in GitHub Desktop.
Puppet Extension Point
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AST::VarDef | |
AST::Variable(file) | |
AST::Function(basename) | |
AST::String(...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope.setvar('file', scope.function_basename('...')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VARIABLE(file) EQUALS NAME(basename) LPAREN STRING(...) RPAREN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$file = basename('/var/lib/puppet/ssl/certs/mycert.pem') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Puppet::Parser::Functions | |
newfunction(:basename, :type => :rvalue, :doc => <<-EOS | |
Returns the basename of a full pathname. For instance if called | |
with '/path/to/myfile.txt' will return 'myfile.txt'. | |
EOS | |
) do |args| | |
raise(Puppet::ParseError, "basename(): Wrong number of arguments given (#{args.size} instead of 1)") if arguments.size != 1 | |
File.basename(args[0]) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# drop this in a module lib/facter/ | |
Facter.add("hardware_platform") do | |
setcode do | |
%x{/bin/uname -i}.chomp | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment