I just rewrote an LWRP as a new custom resource, and ran into what smells like a bug, but could just be an oddity with how the new custom resources function.
Given this (abbreviated) code for a baragon_agent
resource:
default_action :create
property :group, String, name_attribute: true
property :port, Integer, required: true
property :config, Hash, required: true
property :templates, Array, required: true
action :create do
file "/etc/baragon/agent-#{group}.yml" do
mode 0644
content yaml_config(agent_yaml)
notifies :restart, "service[baragon-agent-#{group}]"
end
And a call in the recipe to:
baragon_agent 'default' do
port 8882
config node['baragon']['agent_yaml'].to_hash
templates node['baragon']['templates'].values
end
I end up with an error, b/c it tries to notify service[baragon-agent-]
(i.e., it doesn’t seem to pass group
in to the notifies
properly).
However, if the resource is:
action :create do
agent_yaml['loadBalancerConfig']['name'] = group
file "/etc/baragon/agent-#{group}.yml" do
mode 0644
content yaml_config(agent_yaml)
notifies :restart, "service[baragon-agent-#{agent_yaml['loadBalancerConfig']['name']}]"
end
It works!
Ideas?