[Unit]
Description=Setup {{ device_name }} device
DefaultDependencies=no
After=systemd-udev-settle.service
Before=lvm2-activation-early.service
Wants=systemd-udev-settle.service

[Service]
{# The command is prefixed with '-' to consider it a success if the loopback device is already setup #}
ExecStart=-/sbin/losetup {{ device_name }} {{ file }}
{# In order to Salt can recognize oneshot service as running, we need it to remain active after it exited #}
RemainAfterExit=true
Type=oneshot

[Install]
WantedBy=local-fs.target