windows_service resource multiple actions?

I need to insure two things with respect to the Windows Time Service: it
should be configured to run automatically and it must be started. If no
action is taken in a recipe, the node comes up with the service set to
manual and stopped. So I think the recipe must take two actions, but I
can’t seem to reliably get the desired behavior.

Initially, I thought each resource could only take one action, so I used:

windows_service ‘Configure Windows Time’ do
service_name 'W32Time’
action :configure_startup
startup_type :automatic
end

windows_service ‘Start Windows Time’ do
service_name 'W32Time’
action :start
end

That seemed to update the startup type to automatic, but did not start it.
After further research, I got the impression that a single resource could
have multiple actions, so I tried:

windows_service ‘Configure Windows Time’ do
service_name 'W32Time’
action :configure_startup
startup_type :automatic
action :start
end

That got it started, but left the startup type as manual.

How do I effectively take two actions on this service resource?

On Mon, Sep 14, 2015 at 7:32 PM, David Sopscak dsopscak@gmail.com wrote:

I need to insure two things with respect to the Windows Time Service: it
should be configured to run automatically and it must be started. If no
action is taken in a recipe, the node comes up with the service set to
manual and stopped. So I think the recipe must take two actions, but I can't
seem to reliably get the desired behavior.

Initially, I thought each resource could only take one action, so I used:

windows_service 'Configure Windows Time' do
service_name 'W32Time'
action :configure_startup
startup_type :automatic
end

windows_service 'Start Windows Time' do
service_name 'W32Time'
action :start
end

That seemed to update the startup type to automatic, but did not start it.
After further research, I got the impression that a single resource could
have multiple actions, so I tried:

windows_service 'Configure Windows Time' do
service_name 'W32Time'
action :configure_startup
startup_type :automatic
action :start
end

That got it started, but left the startup type as manual.

How do I effectively take two actions on this service resource?

You want:

windows_service 'Configure Windows Time' do
service_name 'W32Time'
action [:configure_startup, :start]
startup_type :automatic
action :start
end

  • Julian

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]