skx / marionette

Something like puppet, for the localhost only.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update our conditional support

skx opened this issue · comments

Right now we can use exists path/to/file for the if and unless tokens.

We should allow string comparisions, so I'm going to change the syntax to be function-like:

 "if" => "exists( /path/to/file)"
 "if" => "equals( \"${distribution}\", \"Debian\" )"

However the problem there is that the strings are quoted, which is a pain. Single tokens are OK.

Having slept on this I'm going to take a stab at it, and change the syntax at the same time.

if and unless are magical, and special, already. So I think it is actually somewhat reasonable to break the syntax a little for them:

  "if" => exists( /bin/ls ),
  "unless" => equal( `/bin/arch`, "x86-64" ),

What I'm doing there is changing the value of the quoted keys (if and unless) to be an expression, rather than a string. That immediately makes it more obvious how to handle string-arguments. They're just quoted, or backtick'd as appropriate. We don't have to worry about this:

  "if" => "equal( \"foo\", `ls` )",