Reputation: 279
Is there a way to do something when the values change in a Chef Data Bag.
Lets say a data bag looks like this.
{
"data": {
"version": "1.0.12-SNAPSHOT"
}
}
and it changes to this
{
"data": {
"version": "1.0.13"
}
}
is there a way for a Chef resource to 'Subscribe' to this change or this change to 'Notify' a Resource of the change?
Upvotes: 1
Views: 474
Reputation: 55888
The common solution for this is not to subscribe to the change in the data bag but to sensibly handle the result of the change.
It seems that you describe a version of a software to be installed there. Thus, a sensible approach would be to perform these steps during each chef run:
That way, you don't need any actual publish/subscribe architecture but just handle everything during your regular chef runs.
In fact, this general approach is how about all providers in Chef work: check the current state and adapt it if it differs from the intended state as defined by the recipe.
Upvotes: 2