openstack-ansible-lxc_hosts/templates/lxc-dnsmasq-systemd-init.j2
Antony Messerli d1c45fb0cb Use pkill for lxc-dnsmasq systemd unit file
Previously psmisc was not installed by default, causing
the killall in the lxc-dnsmasq systemd unit file to
silently fail if killall wasn't found.  This prevented
running instances of dnsmasq to be torn down when
restarting the service.

This would exhibit as a problem during upgrades as
the older dnsmasq service would be running and the
new service would be unable to take over the port.
This would cause lxc containers to lose connectivity.

This commit switches to using pkill and ensures procps
is always installed by default.

Change-Id: I4fa838706f1163fd68ff68258bfc66cbf13bad94
2019-04-11 11:04:51 -05:00

44 lines
1.0 KiB
Django/Jinja

# {{ ansible_managed }}
[Unit]
Description=lxc dnsmasq service
After=network-online.target
Before=lxc.service
[Service]
Type=simple
User=root
{% if lxc_net_manage_iptables | bool %}
ExecStartPre=/usr/local/bin/lxc-system-manage iptables-create
{% endif %}
ExecStartPre=-/usr/bin/pkill -u {{ lxc_net_dnsmasq_user }} "^dnsmasq"
ExecStart=/usr/local/bin/lxc-system-manage dnsmasq-start
ExecStop=-/usr/local/bin/lxc-system-manage dnsmasq-stop
{% if lxc_net_manage_iptables | bool %}
ExecStopPost=-/usr/local/bin/lxc-system-manage iptables-remove
{% endif %}
PIDFile=/run/lxc/dnsmasq.pid
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=120
Restart=on-failure
RestartSec=2
# This creates a specific slice which all services will operate from
# The accounting options give us the ability to see resource usage through
# the `systemd-cgtop` command.
Slice=lxc-dnsmasq.slice
CPUAccounting=true
BlockIOAccounting=true
MemoryAccounting=false
TasksAccounting=true
[Install]
WantedBy=multi-user.target