pretty print site manifest?
Is there a script (ideally perl) that will look through and pretty-print my site manifest?
Something that will go through my various profiles and nodes, propogate default values, and print a list of values at the end?
I'm currently running puppet master compile HOSTNAME
repeatedly, but as I get more hosts, my script takes longer and longer to complete. I don't really need a full puppet compile
, I just want to see how the values end up.
I could probably write one in perl, but I know that other people could write a better one.
EDIT
Apparently I wasn't clear with what I'm looking for. I think "pretty print" was the wrong term to use. I apologize.
Given this sample setup, where I have a class with variables with default values, a class that is built upon that class with different default values, and two nodes (we use the term "string" to refer to machines being a test machine, a production machine, etc)
class profiles::generic
(
$patchstring,
$patchhour = 12,
$patchminute = 0,
)
{
class { 'systempatch' :
string => $patchstring,
hour => $patchhour,
minute => $patchminute,
}
}
class profiles::teststring
(
$patchstring = 'test',
$patchhour = 13,
$patchminute = 0,
)
{
class { 'profiles::generic' :
patchstring => $patchstring,
patchhour => $patchhour,
patchminute => $patchminute,
}
node 'cutlass'
{
class { 'profiles::generic' :
patchstring => 'prod',
patchminute => 30,
}
}
node 'volvo'
class { 'profiles::teststring' :
patchminute => 20,
}
}
I would like an output that tells me
- cutlass
- systempatch
- string = "prod"
- hour = 12
- minute = 30
- volvo
- systempatch
- string = "test"
- hour = 13
- minute = 20
As I said, I could probably write one, but if one exists, it will probably be a better one than mine.
puppet lint http://puppet-lint.com/ is not about pretty printing but style checking https://docs.puppet.com/guides/style_guide.html (pretty printing is not about compiling)
I think he means the pson file being minified instead of indented and beeline seperated. That part is easy, either install jq and pipe it through there, or through python -m json.tool
Given your latest edit, pretty printing is not what you're asking for. Pretty printing is about style adjustments, making your code actually printable (on paper) w/o looking gross. What you describe, is accessing the parser tree. see pp parser class http://rubydoc.info/gems/puppet/Puppet/Parser/AST