50 lines
1.7 KiB
Django/Jinja
50 lines
1.7 KiB
Django/Jinja
#jinja2: lstrip_blocks: True
|
|
{{ ansible_managed | comment }}
|
|
[Unit]
|
|
Description=Woodpecker Agent ({{ __woodpecker_agent_name }})
|
|
|
|
Wants=docker.service
|
|
After=docker.service
|
|
|
|
[Service]
|
|
Restart=on-failure
|
|
RestartSec=5s
|
|
EnvironmentFile=/etc/environment
|
|
|
|
ExecStop=/usr/bin/docker pull {{ woodpecker_agent_image }}
|
|
ExecStop=/bin/sh -c '/usr/bin/docker ps | /bin/grep %p 1> /dev/null && /usr/bin/docker stop %p || true'
|
|
|
|
ExecStartPre=/bin/sh -c '/usr/bin/docker ps | /bin/grep %p 1> /dev/null && /usr/bin/docker kill %p || true'
|
|
ExecStartPre=/bin/sh -c '/usr/bin/docker ps -a | /bin/grep %p 1> /dev/null && /usr/bin/docker rm %p || true'
|
|
ExecStartPre=/usr/bin/docker pull {{ woodpecker_agent_image }}
|
|
|
|
ExecStart=/usr/bin/docker run --rm \
|
|
--name %p \
|
|
--hostname %p \
|
|
--env-file /etc/sysconfig/woodpecker-agent-{{ __woodpecker_agent_name }} \
|
|
{% if woodpecker_agent_network is defined and woodpecker_agent_network %}
|
|
--network {{ woodpecker_agent_network }} \
|
|
{% endif %}
|
|
{% if woodpecker_agent_cap_add | length > 0 %}
|
|
--cap-add {{ woodpecker_agent_cap_add | join (" ") }}
|
|
{% endif %}
|
|
{% if woodpecker_agent_cap_drop | length > 0 %}
|
|
--cap-drop {{ woodpecker_agent_cap_drop | join (" ") }}
|
|
{% endif %}
|
|
{% for volume in woodpecker_agent_volumes %}
|
|
--mount '{{ "type=bind," if (volume.type | default(False) | lower == "bind") else "" }}src={{ volume.name }},target={{ volume.dest }}' \
|
|
{% endfor %}
|
|
{% for port in woodpecker_agent_exposed_ports %}
|
|
--publish {{ port }} \
|
|
{% endfor %}
|
|
{% for item in inst.docker_args | default(woodpecker_agent_docker_args) %}
|
|
{{ item }} \
|
|
{% endfor %}
|
|
--health-interval 5s \
|
|
--health-retries 5 \
|
|
--health-timeout 10s \
|
|
{{ woodpecker_agent_image }}
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|