On Fri, May 6, 2011 at 18:49, Christopher Browne <cbbro...@afilias.info>wrote:
> On Fri, May 6, 2011 at 12:05 PM, <no-re...@cfengine.com> wrote: > > Forum: Cfengine Help > > Subject: Re: Running a command just once. > > Author: jeromebaum > > Link to topic: > https://cfengine.com/forum/read.php?3,21797,21800#msg-21800 > > > > All of these only if necessary. I can see handling #1 -- just check if > the database exists. #2 dito, #3 would be a bit more hard but I guess dito. > #4 is the troublesome thing. How do I know if "the dump has been imported" > in a clean fashion? Check if there is "some data" in the DB? What if it was > partially applied? etc. > > In effect, you have a non-idempotent process. > > It needs to be more like: > > 1. If database does not exist then > 1.1 Create database > 2. If schema seems not to be loaded then > 2.1 Load schema > 3. Load stored procedures (this is quite likely idempotent-ish > already), but perhaps with a "guard" that says, "don't do it if > they're already there!" > 4. If schema is empty then > 4.1 Load data dump into schema > This is exactly what I was describing. I should have been more explicit. The hint about the guard is a good one. > In a database that supports transactional DDL, I'd be keen on loading > the schema in as a single transaction, so it would either *ALL* load, > or *ALL* fail, so that the "partial" question doesn't emerge. > > Most databases these days support loading data in a transaction, which > makes it mighty attractive for "load data dump" to come as a single > transaction (assuming it's not so large you have to worry about Oracle > rollback segment size, or such), so that, again, it'll either "all > load" or "all fail." I am still worried whether cfengine is the right tool for this. It's not that I want to keep bringing the system into the "database has exactly <dump> as its content" state -- I just initially want to get it there. So, I am trying to converge to any of a set of states, and the dump would bring us to one of those. From that viewpoint, is cfengine "right" for the job? So I am thinking: states: A, B1, B2, B3, ... Initially I am in state A. I want to get into any Bx state. I know a transition A --> B9, and I will apply it whenever in state A. But when in state Bx where x != 9, I will not apply it. Does that make sense?
_______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine