As submitted by dclark
Here is an example of maintaining the bcfg2 server’s /var/lib/bcfg2/Metadata/clients.xml file using Genshi templates.
There are two main advantages:
There is the disadvantage that sometimes 2 passes will be needed to get to a consistent state.
Possible improvements:
Cfg/var/lib/bcfg2/Metadata/clients.xml/clients.xml.genshi:
<!-- Do not edit this file directly - edit only the above template --> {# Doc: http://bcfg2.org/wiki/Authentication #}\ {% def static(profile,name,address) %} <Client profile="${profile}" name="${name}" uuid="${name}" password="${metadata.Properties['passwords.xml'].xdata.find('password').find('bcfg2-client').find(name).text}" address="${address}" location="fixed" secure="true" />\ {% end %}\ {% def dynamic(profile,name) %} <Client profile="${profile}" name="${name}" uuid="${name}" password="${metadata.Properties['passwords.xml'].xdata.find('password').find('bcfg2-client').find(name).text}" floating="true" secure="true" />\ {% end %}\ <Clients version="3.0">\ ${static('group-server-collab','campaigns.example.com','192.168.111.1')} ${static('group-server-collab','info.office.example.com','192.168.111.2')} ${static('group-server-config','config.example.com','192.168.111.3')} ${dynamic('group-project-membercard','membercard')} ${dynamic('group-person-somename','somename.office.example.com')} </Clients>Properties/passwords.xml snippit:
<Properties> <password> <bcfg2-client> <campaigns.example.com>FAKEpassword1</campaigns.example.com> <info.office.example.com>FAKEpassword2</info.office.example.com> <config.example.com>FAKEpassword3</config.example.com> <membercard>FAKEpassword4</membercard> <somename.office.example.com>FAKEpassword5</somename.office.example.com> </bcfg2-client> </password> </Properties>