In a chef recipe I define a helper method like:
def my_service_config(description, args="")
{
Unit: {
Description: description,
},
Service: {
Type: 'simple',
ExecStart: "/usr/sbin/my-service-script #{args}",
Restart: 'on-failure',
}
}
end
systemd_unit "my-service.service" do
content my_service_config("my description", "--some-flag")
action :create
end
But when I run chef I get an error like:
NoMethodError
-------------
undefined method `my_service_config' for Chef::Resource::SystemdUnit
How can I properly refer to the my_service_config method from inside the systemd_unit resource block?