Merge pull request #522 from lookslikematrix/master

Allow the start command of the Docker service to be overwritten.
This commit is contained in:
Jeff Geerling 2025-10-15 13:10:19 -05:00 committed by GitHub
commit f18164a64b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 0 deletions

View File

@ -54,6 +54,7 @@ A list of packages to be uninstalled prior to running this role. See [Docker's i
docker_service_manage: true
docker_service_state: started
docker_service_enabled: true
docker_service_start_command: ""
docker_restart_handler_state: restarted
```

View File

@ -23,6 +23,7 @@ docker_obsolete_packages:
docker_service_manage: true
docker_service_state: started
docker_service_enabled: true
docker_service_start_command: ""
docker_restart_handler_state: restarted
# Docker Compose Plugin options.

View File

@ -68,6 +68,25 @@
when: docker_daemon_options.keys() | length > 0
notify: restart docker
- name: Replace Docker service ExecStart command.
when: docker_service_start_command != ""
notify: restart docker
block:
- name: Get Docker service status
ansible.builtin.systemd_service:
name: docker
register: docker_service_status
- name: Patch docker.service
ansible.builtin.replace:
path: "{{ docker_service_status.status['FragmentPath'] }}"
regexp: "^ExecStart=.*$"
replace: "ExecStart={{ docker_service_start_command }}"
register: docker_service_patch
- name: Reload systemd services
service:
daemon_reload: true
when: docker_service_patch.changed
- name: Ensure Docker is started and enabled at boot.
service:
name: docker