Reputation: 440
My custom cookbook installs openvpn in the following way:
package 'openvpn'
... do some configuration ....
service 'openvpn' do
action [:enable, :start]
end
Code above works fine in centos 6 and fails in centos 7 (systemd)
Error: /bin/systemctl enable openvpn - No such file or directory
It seams that on systemd the name of the service is different: openvpn@server How can I detect this?
Upvotes: 0
Views: 252
Reputation: 4185
You can check platform_version (assuming you are already checking platform for CentOS in your cookbook) then switch the service_name on the fly. For example, to start OpenVPN server
service 'openvpn_service' do
if node['platform_version'].to_f >= 7.0
service_name '[email protected]'
else
service_name 'openvpn'
end
action [ :enable, :start ]
end
Upvotes: 2