Ok, I'm thoroughly stumped here. I had something from testing several months ago that I thought was doing the right thing, but now I don't think it was.
I want to insert into ~root/.ssh/known_hosts on certain hosts the root public ssh key from a trusted root host. But the trickier part is to delete any lines from the known_hosts file that match the beginning and end of the new key to be added without affecting any other lines. For example, say I have $(trustedhostkey) = "ssh-dss blahblahblahblah r...@trustedhost" and in the local ~root/.ssh/known_hosts file: ssh-dss someoldkeytexthere r...@trustedhost ssh-dss someotherkeytextab r...@anotherhost I just want to replace the first line with $(trustedhostkey) since the whole line doesn't match the new key but it does match ssh-dss at the beginning and r...@trustedhost at the end. (If the right key is already in the file, then it can be left alone.) Before I had something like vars: "key" string => remotescalar("root_key", "trustedhost", "yes"); # yes = encryption "key_fields" slist => splitstring("$(key)", " ", 3) delete_lines: "$(key_fields[0]) .* $(key_fields[2])"; insert_lines: "$(key)"; But now I've noticed that the indexing of an slist doesn't work. I've been playing around with replace_patterns, trying to figure out how I might use $(match.N) backrefs, but no success yet. Any thoughts on how to do this? Thanks, Justin This electronic communication and any attachments may contain confidential and proprietary information of DigitalGlobe, Inc. If you are not the intended recipient, or an agent or employee responsible for delivering this communication to the intended recipient, or if you have received this communication in error, please do not print, copy, retransmit, disseminate or otherwise use the information. Please indicate to the sender that you have received this communication in error, and delete the copy you received. DigitalGlobe reserves the right to monitor any electronic communication sent or received by its employees, agents or representatives. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine