[Unit]
Description=Openstack Keystone Container
After=docker.service
Requires=docker.service

[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker kill %n
ExecStartPre=-/usr/bin/docker rm %n
ExecStart=/usr/bin/docker run --name %n \
  --add-host=mariadb:{{ hostvars[groups['databases'][0]]['listen_ip'] | default(hostvars[groups['databases'][0]]['ansible_default_ipv4']['address']) }} \
  -e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['listen_ip'] | default(hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address']) }}" \
  -p 5000:5000 -p 35357:35357 \
  -v /srv/keystone/fernet-keys:/etc/keystone/fernet-keys \
  -v /srv/keystone/root:/root \
  {{ docker_image }}

[Install]
WantedBy=multi-user.target