<div dir="ltr">Hey, Xavier.<div><br></div><div>Thanks for the follow-up.</div><div><br></div><div><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><span class=""><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">> 1) creating 'tags' if not present<u></u><u></u></span></p></span><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">set $datadog/tags<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">… will create a 'tags' node (in last position) on root level if it doesn't exist yet, otherwise nothing will happen. ($datadog contains the path to your datadog.ini file)</span></p></div></blockquote><div><br></div><div><br></div><div>Ultimately this lens is going to be used from Puppet and my 'tag' key should *always* exist as /<file>/Main/tags so it seems to make sense to handle that end of things with the tools which Puppet provides even if I were not able to figure it out at the augeas level.</div><div><br></div><div> <span style="color:rgb(31,73,125);font-family:Calibri,sans-serif;font-size:11pt"> </span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><span class=""><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">> 2) checking the tag string for the presence of my key:value pair<u></u><u></u></span></p></span><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Use 'print' or 'match' with a suitable xpath expression.</span></p></div></blockquote><div><br></div><div><br></div><div>This is the part which is tripping me up. I can't figure out which fields are available for query of a node when a lens is based off ot the INIFile lens. For instance, this makes sense for /etc/hosts because I have 'ipaddr' and 'canonical':</div><div><br></div><div>```</div><div><div>augtool> print /files/etc/hosts</div><div>/files/etc/hosts</div><div>/files/etc/hosts/1</div><div>/files/etc/hosts/1/ipaddr = "127.0.0.1"</div><div>/files/etc/hosts/1/canonical = "localhost"</div><div>...</div><div>augtool> match  /files/etc/hosts/*/ipaddr[../canonical = "localhost"]</div><div>/files/etc/hosts/1/ipaddr = 127.0.0.1</div></div><div>```</div><div><br></div><div>Translating to English, "I'd like the value of the 'ipaddr' field for all entries for which the 'canonical' field is 'localhost'.</div><div><br></div><div>Trying to do something similar for an INIFile based filed...I can't figure out what my fields might be for a match so I'm left with an explicit path only to get to the 'tag' data:</div><div><br></div><div>```</div><div><div>augtool> print /files/etc/dd-agent/datadog.conf</div></div><div>...</div><div><div>/files/etc/dd-agent/datadog.conf/Main/#comment[132] = "connection will be attempted"</div><div>/files/etc/dd-agent/datadog.conf/Main/log_to_syslog = "yes"</div><div>/files/etc/dd-agent/datadog.conf/Main/#comment[133] = "syslog_host:"</div><div>/files/etc/dd-agent/datadog.conf/Main/#comment[134] = "syslog_port:"</div><div>/files/etc/dd-agent/datadog.conf/Main/augeas_key = "canary_value"</div></div><div><div>/files/etc/dd-agent/datadog.conf/Main/#comment[135] = "augeas comment"</div></div><div><div>augtool> print /files/etc/dd-agent/datadog.conf/Main/tags</div><div>/files/etc/dd-agent/datadog.conf/Main/tags = "owner:nrvale0, interactive_users:nrvale0"</div></div><div><br></div><div><div>augtool> match /files/etc/dd-agent/datadog.conf/*/</div><div>/files/etc/dd-agent/datadog.conf/#comment = MANAGED BY PUPPET</div><div>/files/etc/dd-agent/datadog.conf/Main = (none)</div></div><div><br></div><div>augtool> </div><div>```<br></div><div><br></div><div>In the end I guess the explicit path to the data is ok (maybe the intent of INIFile is such that complicated queries are not that important?) but I'm then not certain how, from within Puppet or within augeas, to say:</div><div><br></div><div>"If my new tag 'foo:bar' is not already at /files/etc/dd-agent/datadog.conf/Main/tags then go ahead and append it. Puppet doesn't provide a great way to query a resource's value, check it + possibly alter it, and then reapply it so I'm hoping there is XPATH syntax to do it. In the example above there the desired result would look like so:</div><div><br></div><div>/etc/etc/dd-agent/datadog.conf/Main/tags = "owner:nrvale0, interactive_users,:nrvale0, foo:bar"</div></div>
</div></div>