Update file main.yml
This commit is contained in:
parent
3dd4e1c37f
commit
68536caed0
@ -17,16 +17,18 @@
|
|||||||
- "{{ cadvisor_config_dir }}"
|
- "{{ cadvisor_config_dir }}"
|
||||||
become: yes
|
become: yes
|
||||||
|
|
||||||
- name: Check if any container is using port {{ cadvisor_port }}
|
- name: Check if port {{ cadvisor_port }} is available
|
||||||
shell: |
|
shell: |
|
||||||
docker ps --format "table {{.Names}}\t{{.Ports}}" | grep {{ cadvisor_port }} || true
|
if ss -tuln | grep -q ":{{ cadvisor_port }} "; then
|
||||||
register: port_usage
|
echo "Port {{ cadvisor_port }} is in use"
|
||||||
become: no
|
exit 1
|
||||||
|
else
|
||||||
- name: Fail if port {{ cadvisor_port }} is in use
|
echo "Port {{ cadvisor_port }} is available"
|
||||||
fail:
|
exit 0
|
||||||
msg: "Port {{ cadvisor_port }} is already in use by another container"
|
fi
|
||||||
when: port_usage.stdout != ""
|
register: port_check
|
||||||
|
ignore_errors: yes
|
||||||
|
become: no
|
||||||
|
|
||||||
- name: Deploy cAdvisor docker-compose
|
- name: Deploy cAdvisor docker-compose
|
||||||
template:
|
template:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user