I’ve decided to refactor my cookbooks and to separate the logic of
creating and initial filling mysql databases into the lightweight
resource. I took MysqlDatabase as a basis.
The idea was to create a database if one doesn’t exist,
then to create the database user if it’s name & password are specified
and to fill the database with supplied data, if it’s empty.
Unfortunately, I’ve run into the troubles while writing the provider
action. Conditional statements of the action body are evaluated before
resources defined above are run. For example, I can’t make a test
whether the database is empty because It would be created later than my
test and corresponding ‘if’ statement is evaluated.
I think it’s a frequent problem. I’d like the hear some thoughts and
advices on how to avoid it.