I don't have any examples handy, but the easiest way to try out managing 
the file with Puppet is to store it somewhere, say /tmp/file.json and then 
play around with it in augtool:

augtool -A -t 'Json incl /tmp/file.json'
augtool> match /files/tmp/file.json/dict/entry[. = 'svc_port']/*
/files/tmp/file.json/dict/entry[2]/string = 12345
augtool> set /files/tmp/file.json/dict/entry[. = 'svc_port']/string 4242
augtool> rm /files/tmp/file.json/dict/entry[. = 'svc_pass']
rm : /files/tmp/file.json/dict/entry[. = 'svc_pass'] 2
augtool> save
Saved 1 file(s)
augtool> quit

> cat /tmp/file.json
...

David

On Friday, November 1, 2013 11:57:25 AM UTC-7, John Simpson wrote:
>
> Greetings. 
>
> I'm trying to find a few concrete examples of how to use augeas within a 
> Puppet module, to make changes to a JSON file. I've been googling for the 
> past hour and a half, and while I have found several pages which provide 
> reference-type documentation, I have yet to see a single usable example. 
> All of the augeas examples seem to demonstrate how to maintain a file for 
> which some other lens applies, such as /etc/hosts or /etc/ssh/sshd_config. 
>
> My situation: I have a system-wide JSON file which contains a series of 
> key-value pairs, like so: 
>
> { 
>   "svc_host" : "server.domain.xyz" , 
>   "svc_port" : "12345" , 
>   "svc_user" : "username" , 
>   "svc_pass" : "password" , 
>
>   "versions" : [ "1.0" , "1.0.1" , "1.0.2" ] , 
>
>   "agent_installed" : "1383331588" , 
>
>   "comment"  : "This is a gratuitous comment." 
> } 
>
> I know that JSON is probably not be the best format for the file, but it's 
> human readable, and it saves us having to write and debug configuration 
> file parsing routines in seven different languages on four platforms. 
>
> I would like to be able to use Puppet modules to maintain the file. My 
> first thought, of course, was to use a template, but there are several 
> different components of the system which all store data in the one file, so 
> different modules need to maintain different sets of "keys" within the 
> file. 
>
> Is anybody doing something similar, and if so, would you mind sharing the 
> relevant bits of your manifests? Or point me to an example of a WORKING 
> augeas resource which adds or 
>
> -- 
> John Simpson <jm...@voalte.com <javascript:>> 
> Unix System/VM Developer and Engineering Operations, Voalte 
> +1 (941) 312-2830 x148 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/73eb3b9e-8113-4935-96fe-bc19febfba9e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to