-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fails if network_mode container does not exist or is unhealthy. closes #172
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
resources/tasks/docker/network_container_health_status.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
############################################################################################ | ||
# Title: Saltbox: Resources | Tasks | Docker | Networked Container Health Status # | ||
# Author(s): salty # | ||
# URL: https://github.com/saltyorg/Saltbox # | ||
# -- # | ||
############################################################################################ | ||
# GNU General Public License v3.0 # | ||
############################################################################################ | ||
--- | ||
- name: Resources | Tasks | Docker | Network Container Health Status | Check health of network linked container | ||
community.docker.docker_container_info: | ||
name: "{{ lookup('vars', _var_prefix + '_docker_network_mode', default=docker_networks_name_common).split(':')[1] }}" | ||
register: docker_info | ||
|
||
- name: Resources | Tasks | Docker | Network Container Health Status | Fail if network linked container does not exist | ||
ansible.builtin.fail: | ||
msg: "{{ lookup('vars', _var_prefix + '_docker_container', default=_var_prefix) }} is configured to use {{ lookup('vars', _var_prefix + '_docker_network_mode', default=docker_networks_name_common).split(':')[1] }} for networking but it does not exist" | ||
when: not docker_info.exists | ||
|
||
- name: Resources | Tasks | Docker | Network Container Health Status | Fail if network linked container is not healthy | ||
ansible.builtin.fail: | ||
msg: "{{ lookup('vars', _var_prefix + '_docker_container', default=_var_prefix) }} is configured to use {{ lookup('vars', _var_prefix + '_docker_network_mode', default=docker_networks_name_common).split(':')[1] }} for networking but it is not healthy" | ||
when: ('State' not in docker_info.container or 'Health' not in docker_info.container.State or 'Status' not in docker_info.container.State.Health or docker_info.container.State.Health.Status != 'healthy') |