feat: only allow starting and managing running services.
All checks were successful
test / Retrieve Credentials (pull_request) Successful in 2s
development / Check commit compliance (push) Successful in 5s
pull-requests-open / Check commit compliance (pull_request) Successful in 5s
test / end_to_end_role (default, debian11) (pull_request) Successful in 39s
test / end_to_end_role (default, debian12) (pull_request) Successful in 40s
test / end_to_end_role (default, ubuntu2004) (pull_request) Successful in 40s
test / end_to_end_role (default, ubuntu2204) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, debian11) (pull_request) Successful in 37s
test / end_to_end_role (default, ubuntu2404) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, ubuntu2204) (pull_request) Successful in 38s
test / end_to_end_role (with_custom_flags, debian12) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, ubuntu2004) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, ubuntu2404) (pull_request) Successful in 38s
All checks were successful
test / Retrieve Credentials (pull_request) Successful in 2s
development / Check commit compliance (push) Successful in 5s
pull-requests-open / Check commit compliance (pull_request) Successful in 5s
test / end_to_end_role (default, debian11) (pull_request) Successful in 39s
test / end_to_end_role (default, debian12) (pull_request) Successful in 40s
test / end_to_end_role (default, ubuntu2004) (pull_request) Successful in 40s
test / end_to_end_role (default, ubuntu2204) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, debian11) (pull_request) Successful in 37s
test / end_to_end_role (default, ubuntu2404) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, ubuntu2204) (pull_request) Successful in 38s
test / end_to_end_role (with_custom_flags, debian12) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, ubuntu2004) (pull_request) Successful in 39s
test / end_to_end_role (with_custom_flags, ubuntu2404) (pull_request) Successful in 38s
destroying/removing services should be handled separately, most likely by the end user's custom code, to avoid data loss, etc...
This commit is contained in:
parent
cbde72a17f
commit
ffbb6157ef
@ -1,14 +0,0 @@
|
||||
---
|
||||
# docker_systemd_service_container_name: "My-Service"
|
||||
# docker_systemd_service_image:
|
||||
# docker_systemd_service_container_env: {}
|
||||
# docker_systemd_service_container_pull_image: true
|
||||
# docker_systemd_service_container_pull_force_source: true
|
||||
# docker_systemd_service_flags: []
|
||||
# docker_systemd_service_container_cmd: []
|
||||
# docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
|
||||
# docker_systemd_service_systemd_options: []
|
||||
# docker_systemd_service_enabled: true
|
||||
# docker_systemd_service_masked: false
|
||||
# docker_systemd_service_state: started
|
||||
# docker_systemd_service_restart: true
|
@ -9,7 +9,5 @@ docker_systemd_service_flags: []
|
||||
docker_systemd_service_container_cmd: []
|
||||
docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
|
||||
docker_systemd_service_systemd_options: []
|
||||
docker_systemd_service_enabled: true
|
||||
docker_systemd_service_masked: false
|
||||
docker_systemd_service_state: started
|
||||
docker_systemd_service_restart: true
|
||||
|
||||
docker_systemd_service_start: true
|
||||
|
@ -8,7 +8,4 @@ docker_systemd_service_flags: []
|
||||
docker_systemd_service_container_cmd: []
|
||||
docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
|
||||
docker_systemd_service_systemd_options: []
|
||||
docker_systemd_service_enabled: true
|
||||
docker_systemd_service_masked: false
|
||||
docker_systemd_service_state: stopped
|
||||
docker_systemd_service_restart: false
|
||||
docker_systemd_service_start: false
|
||||
|
@ -24,7 +24,7 @@
|
||||
- stat_etc_default_nginx.stat.pw_name == 'root'
|
||||
- stat_etc_default_nginx.stat.gr_name == 'root'
|
||||
- stat_etc_default_nginx.stat.mode == '0600'
|
||||
- (slurp_etc_default_nginx.content|b64decode) == ''
|
||||
- (slurp_etc_default_nginx.content|b64decode) == '\n'
|
||||
|
||||
- name: "Test: service nginx_container"
|
||||
block:
|
||||
|
@ -8,7 +8,4 @@ docker_systemd_service_flags: []
|
||||
docker_systemd_service_container_cmd: []
|
||||
docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
|
||||
docker_systemd_service_systemd_options: []
|
||||
docker_systemd_service_enabled: true
|
||||
docker_systemd_service_masked: false
|
||||
docker_systemd_service_state: started
|
||||
docker_systemd_service_restart: true
|
||||
docker_systemd_service_start: true
|
||||
|
@ -24,7 +24,7 @@
|
||||
- stat_etc_default_nginx.stat.pw_name == 'root'
|
||||
- stat_etc_default_nginx.stat.gr_name == 'root'
|
||||
- stat_etc_default_nginx.stat.mode == '0600'
|
||||
- (slurp_etc_default_nginx.content|b64decode) == ''
|
||||
- (slurp_etc_default_nginx.content|b64decode) == '\n'
|
||||
|
||||
- name: "Test: service nginx_container"
|
||||
block:
|
||||
|
@ -13,7 +13,4 @@ docker_systemd_service_flags:
|
||||
docker_systemd_service_container_cmd: []
|
||||
docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
|
||||
docker_systemd_service_systemd_options: []
|
||||
docker_systemd_service_enabled: true
|
||||
docker_systemd_service_masked: false
|
||||
docker_systemd_service_state: stopped
|
||||
docker_systemd_service_restart: false
|
||||
docker_systemd_service_start: false
|
||||
|
@ -13,7 +13,4 @@ docker_systemd_service_flags:
|
||||
docker_systemd_service_container_cmd: []
|
||||
docker_systemd_service_name: "{{ docker_systemd_service_container_name }}_container"
|
||||
docker_systemd_service_systemd_options: []
|
||||
docker_systemd_service_enabled: true
|
||||
docker_systemd_service_masked: false
|
||||
docker_systemd_service_state: started
|
||||
docker_systemd_service_restart: true
|
||||
docker_systemd_service_start: true
|
||||
|
@ -33,13 +33,4 @@
|
||||
_docker_systemd_service_need_restart: true
|
||||
when: _docker_systemd_service_env_file.changed or
|
||||
_docker_systemd_service_unit_file.changed or
|
||||
docker_systemd_service_container_pull_image.changed
|
||||
|
||||
- name: "Docker systemd service | Enable and start service(s)"
|
||||
ansible.builtin.systemd:
|
||||
name: '{{ docker_systemd_service_name }}.service'
|
||||
daemon_reload: true
|
||||
enabled: "{{ docker_systemd_service_enabled }}"
|
||||
masked: "{{ docker_systemd_service_masked }}"
|
||||
state: "{{ docker_systemd_service_state }}"
|
||||
register: _enable_and_start
|
||||
_docker_systemd_service_image_pull.changed
|
@ -5,13 +5,17 @@
|
||||
_docker_systemd_service_need_daemon_reload: false
|
||||
_docker_systemd_service_need_restart: false
|
||||
|
||||
- name: "Docker systemd service | Import install.yml"
|
||||
ansible.builtin.include_tasks: install.yml
|
||||
when: docker_systemd_service_state != "absent"
|
||||
- name: "Docker systemd service | Import configure.yml"
|
||||
ansible.builtin.include_tasks: configure.yml
|
||||
|
||||
- name: "Docker systemd service | Import uninstall.yml"
|
||||
ansible.builtin.include_tasks: uninstall.yml
|
||||
when: docker_systemd_service_state == "absent"
|
||||
- name: "Docker systemd service | Populate service facts"
|
||||
ansible.builtin.service_facts:
|
||||
|
||||
- name: "Docker systemd service | Set restart-check variable"
|
||||
ansible.builtin.set_fact:
|
||||
_docker_systemd_service_need_restart: true
|
||||
when:
|
||||
- ansible_facts.services[docker_systemd_service_name~'.service'].state != 'running'
|
||||
|
||||
- name: "Docker systemd service | Enable service: {{ docker_systemd_service_name }}"
|
||||
ansible.builtin.service:
|
||||
@ -28,4 +32,6 @@
|
||||
name: "{{ docker_systemd_service_name }}"
|
||||
state: restarted
|
||||
throttle: 1
|
||||
when: _docker_systemd_service_need_restart
|
||||
when:
|
||||
- _docker_systemd_service_need_restart
|
||||
- docker_systemd_service_start
|
||||
|
@ -1,22 +0,0 @@
|
||||
---
|
||||
# task/uninstall file for docker_systemd_service
|
||||
- name: "Remove ENV file(s) for service(s)"
|
||||
ansible.builtin.file:
|
||||
path: "{{ docker_systemd_service_sysconf_dir }}/{{ docker_systemd_service_container_name }}"
|
||||
state: absent
|
||||
|
||||
- name: "Disable and stop service(s)"
|
||||
ansible.builtin.systemd:
|
||||
name: '{{ docker_systemd_service_name }}.service'
|
||||
enabled: false
|
||||
state: stopped
|
||||
|
||||
- name: "Remove unit file(s) for service(s)"
|
||||
ansible.builtin.file:
|
||||
path: /etc/systemd/system/{{ docker_systemd_service_name }}.service
|
||||
state: absent
|
||||
|
||||
- name: "Reload systemd units"
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
changed_when: false
|
Loading…
Reference in New Issue
Block a user