support all docker arguments #2

Merged
lanson merged 10 commits from feature/support-all-docker-args into main 2023-12-10 18:09:49 +00:00
7 changed files with 17 additions and 90 deletions
Showing only changes of commit f813944d74 - Show all commits

View File

@ -6,24 +6,7 @@ docker_systemd_service_container_env: {}
docker_systemd_service_container_pull_image: true
docker_systemd_service_container_pull_force_source: true
docker_systemd_service_flags: []
#! TO REPLACE
docker_systemd_service_container_labels: []
docker_systemd_service_container_cmd: []
docker_systemd_service_container_host_network: false
docker_systemd_service_container_network: ""
docker_systemd_service_container_user: ""
docker_systemd_service_container_hostname: ""
docker_systemd_service_container_links: []
docker_systemd_service_container_ports: []
docker_systemd_service_container_hosts: []
docker_systemd_service_container_volumes: []
docker_systemd_service_container_cap_add: []
docker_systemd_service_container_cap_drop: []
docker_systemd_service_container_devices: []
docker_systemd_service_container_privileged: false
docker_systemd_service_container_args: ""
#! END TO REPLACE
docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
docker_systemd_service_systemd_options: []
docker_systemd_service_enabled: true

View File

@ -2,7 +2,9 @@
def create_docker_flags(flags):
return "\n".join([create_docker_flag(item) for item in flags])
if flags:
return "\n".join([create_docker_flag(item) for item in flags])
return None
def create_docker_flag(item):

View File

@ -1,24 +1,11 @@
---
docker_systemd_service_container_name: "nginx"
docker_systemd_service_image: "nginx"
docker_systemd_service_image: nginx
docker_systemd_service_container_env: {}
docker_systemd_service_container_pull_image: false
docker_systemd_service_container_pull_force_source: false
docker_systemd_service_container_labels: []
docker_systemd_service_flags: []
docker_systemd_service_container_cmd: []
docker_systemd_service_container_host_network: false
docker_systemd_service_container_network: ""
docker_systemd_service_container_user: ""
docker_systemd_service_container_hostname: ""
docker_systemd_service_container_links: []
docker_systemd_service_container_ports: []
docker_systemd_service_container_hosts: []
docker_systemd_service_container_volumes: []
docker_systemd_service_container_cap_add: []
docker_systemd_service_container_cap_drop: []
docker_systemd_service_container_devices: []
docker_systemd_service_container_privileged: false
docker_systemd_service_container_args: ""
docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
docker_systemd_service_systemd_options: []
docker_systemd_service_enabled: true

View File

@ -53,20 +53,9 @@
[Service]
EnvironmentFile=/etc/default/nginx
ExecStartPre=-/usr/bin/docker rm -f nginx
ExecStart=/usr/bin/docker run --name nginx --rm --env-file /etc/default/nginx \
\
\
\
\
\
\
\
\
\
\
\
\
\
ExecStart=/usr/bin/docker run --name nginx \
--rm \
--env-file /etc/default/nginx \
nginx
ExecStop=/usr/bin/docker stop nginx
SyslogIdentifier=nginx

View File

@ -1,35 +1,11 @@
---
docker_systemd_service_container_name: "ninx"
docker_systemd_service_container_name: "nginx"
docker_systemd_service_image: nginx
docker_systemd_service_container_env: {}
docker_systemd_service_container_pull_image: true
docker_systemd_service_container_pull_force_source: false
docker_systemd_service_flags:
- health-cmd: curl localhost:80
- health-retries: 10
- privileged
- network: host
- volume:
- /root:/mnt/volume
- /var:/test:ro
docker_systemd_service_container_pull_force_source: true
docker_systemd_service_flags: []
docker_systemd_service_container_cmd: []
#! TO REPLACE
docker_systemd_service_container_labels: []
docker_systemd_service_container_host_network: false
docker_systemd_service_container_network: ""
docker_systemd_service_container_user: ""
docker_systemd_service_container_hostname: ""
docker_systemd_service_container_links: []
docker_systemd_service_container_ports: []
docker_systemd_service_container_hosts: []
docker_systemd_service_container_volumes: []
docker_systemd_service_container_cap_add: []
docker_systemd_service_container_cap_drop: []
docker_systemd_service_container_devices: []
docker_systemd_service_container_privileged: false
docker_systemd_service_container_args: ""
#! END TO REPLACE
docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
docker_systemd_service_systemd_options: []
docker_systemd_service_enabled: true

View File

@ -53,20 +53,9 @@
[Service]
EnvironmentFile=/etc/default/nginx
ExecStartPre=-/usr/bin/docker rm -f nginx
ExecStart=/usr/bin/docker run --name nginx --rm --env-file /etc/default/nginx \
\
\
\
\
\
\
\
\
\
\
\
\
\
ExecStart=/usr/bin/docker run --name nginx \
--rm \
--env-file /etc/default/nginx \
nginx
ExecStop=/usr/bin/docker stop nginx
SyslogIdentifier=nginx

View File

@ -16,11 +16,12 @@ EnvironmentFile={{ docker_systemd_service_sysconf_dir }}/{{ docker_systemd_servi
ExecStartPre=-{{ docker_systemd_service_docker_path }} rm -f {{ docker_systemd_service_container_name }}
{% endif %}
{% if not 'ExecStart' in service_systemd_options_keys %}
{% set docker_flags = docker_systemd_service_flags | create_docker_flags %}
ExecStart={{ docker_systemd_service_docker_path }} run --name {{ docker_systemd_service_container_name }} \
--rm \
--env-file {{ docker_systemd_service_sysconf_dir }}/{{ docker_systemd_service_container_name }} \
{{ docker_systemd_service_flags|create_docker_flags }}
{{ docker_systemd_service_image -}}{{ ' ' if docker_systemd_service_container_cmd else '' }}{% if docker_systemd_service_container_cmd is string %}{{ docker_systemd_service_container_cmd | trim }}{% else %}{{ docker_systemd_service_container_cmd | join(' ') | trim }}{% endif %}
{{ docker_flags -}}{% if docker_flags +%}
{% endif %}{{ docker_systemd_service_image -}}{{ ' ' if docker_systemd_service_container_cmd else '' }}{% if docker_systemd_service_container_cmd is string %}{{ docker_systemd_service_container_cmd | trim }}{% else %}{{ docker_systemd_service_container_cmd | join(' ') | trim }}{% endif %}
{% endif +%}
{% if not 'ExecStop' in service_systemd_options_keys %}
ExecStop={{ docker_systemd_service_docker_path }} stop {{ docker_systemd_service_container_name }}