The systemd_unit only takes a string for the content attribute.
My script is 50+ lines long. Am I expected to take that script and condense it into 1 line?
systemd_unit 'sysstat-collect.timer' do
enabled true
content '[Unit]\nDescription=Run system activity accounting tool every 10 minutes\n\n[Timer]\nOnCalendar=*:00/10\n\n[Install]\nWantedBy=sysstat.service'
end
My workaround for this is to use the reload_command option to the service resource for those cases where I’m altering an existing service or using more than a single config for the systemd_unit. In this case we are moving from docker-engine to docker-ce and needed to update a couple configs, and if either of the files was missing or empty systemctl would hang trying to restart docker during the install.
cookbook_file '/etc/systemd/system/docker.service.d/10-docker.conf' do
source '10-docker.conf'
notifies :reload, 'service[docker]', :immediately
notifies :restart, 'service[docker]', :delayed
not_if { ::File.exist?('/tmp/kitchen') }
end
cookbook_file '/etc/docker/daemon.json' do
source 'daemon.json'
notifies :reload, 'service[docker]', :immediately
notifies :restart, 'service[docker]', :delayed
not_if { ::File.exist?('/tmp/kitchen') }
end
docker_installation_package 'default' do
action :create
version node['docker']['version']
package_options "--force-yes -o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-all'"
end
service 'docker' do
action :nothing
reload_command 'systemctl daemon-reload'
end