Ask Your Question

how can i parse a *.pp file using java

asked 2013-01-06 21:03:03 -0600

jpratt3000 gravatar image

hello everyone - i have a question that is a bit out of the norm. we're currently maintaining most of our environment using puppet and are very happy with it.

in trying to keep our configurations in a single file format, we have a large part of our environment that we cannot run an agent on. we can however access these units and program them with java.

is there a way i can parse a *.pp file or modules using java to get the configurations out of them?

has anyone tried doing this before?

edit retag flag offensive close merge delete


Writing a parser isn't the hardest thing in the world, but it is time consuming and requires significant maintenance with language updates. Could you describe exactly what you want ...(more)

rodjek gravatar imagerodjek ( 2013-01-07 01:28:57 -0600 )edit

I'd take a look at what Geppetto has done personally. Try asking 'helindbe' all about this stuff on #geppetto on IRC, I don't have the answer directly but ...(more)

ken gravatar imageken ( 2013-01-07 10:29:05 -0600 )edit

It might also be worth looking to see if something like jruby can let you load some of the puppet ruby code and use that to parse.

llowder gravatar imagellowder ( 2013-01-07 13:34:10 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-01-10 02:42:30 -0600

updated 2013-01-10 02:43:56 -0600

It looks like what you want is not so much to access the .pp files, but rather to ensure the catalog is applied on machines that cannot run Puppet, but can only run java. In this case, you might be more interested in parsing and applying catalogs rather than .pp files.

Catalogs are YAML files, so it shouldn't be too hard to parse them using Java. As for applying them, you'd have to reimplement large chuncks of Puppet.

That would include rewriting the dependency manager, as well as most types/providers.

edit flag offensive delete link more

answered 2013-01-07 20:00:14 -0600

The "configurations" are much more than just parsing a .pp file. They would have to include facter and/or other external data sources, as well as all of the relational and graph logic of puppet. Essentially, rewriting Puppet in Java. At least if you're making use of modules/classes, defined types, etc.

How about two alternate theories, depending on how much you can do one one host:

1) Have puppet run on a "normal" (i.e. Linux/Unix/etc.) host, and have puppet simply use templates or Augeas to write out files in whatever arbitrary format you want? Why ... (more)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-01-06 21:03:03 -0600

Seen: 269 times

Last updated: Jan 10 '13