We are trying to split a string on a comma and then run an execute resource once for each value in the resulting array.
That part is working. The problem is that we are trying to have this trigger after a notify instead of running every time.
This code works but runs every time.
node.run_state['myapp_secrets'][:QMGR].split.each do |mq_server|
execute 'start myapp instance' do
user node['myapp']['jar']['username']
cwd '/opt/myapp/'
environment({ 'QMGR' => mq_server,
})
command "java -jar /opt/myapp/myapp-all.jar > /dev/null &"
end
end
The problem is that if we notify the execute resource itself it only runs once (and the QMGR environment variable is unset.)
And we can't notify node.run_state['myapp_secrets'][:QMGR].split.each because it's straight ruby code and not a resource.