I want to do the equivalent via the CLI that clicking on the stack, selecting only instances in a specific layer and running Execute Recipes command (or alternatively trigger the Configure lifecycle step).
I need to do this programmatically, there is an option to do it at the Stack level but that does not help,
Trying to avoid something like the following, I will probably end up pulling the layer members into an array and then hitting them independently as suggested below. Not great though since I'll have to add static information for Stack & Layer info.
if deploy[:application_type] != 'php'
Chef::Log.debug("Skipping mod_php5_apache2::php application #{application} as it is not an PHP app")
next
end
You'll have to do this in two steps, firstly get the instances in a specific layer using describe-instances by setting the
--layer-id
argument, then run your command on those instances using create-deployment by setting the--instance-ids
argument.Another option is to make your custom recipes do nothing if they're not executed on the right layer or the app type is wrong. This technique is used quite frequently in the default cookbooks, here's an example of skipping a deploy if it's not a PHP app. You could then run your recipe on all instances but it would only do something on specific layers.