Update ansible/clear.yml
This commit is contained in:
@@ -3,29 +3,32 @@
|
||||
hosts: all
|
||||
become: true
|
||||
gather_facts: false
|
||||
ignore_errors: true
|
||||
|
||||
tasks:
|
||||
# ==========================================
|
||||
# SPRAWDZENIE CZY HOST JEST WŁĄCZONY (SSH)
|
||||
# BEZBŁĘDNE SPRAWDZENIE CZY HOST JEST WŁĄCZONY
|
||||
# ==========================================
|
||||
- name: Sprawdzenie dostępności portu SSH
|
||||
ansible.builtin.wait_for:
|
||||
host: "{{ ansible_host | default(inventory_hostname) }}"
|
||||
port: "{{ ansible_port | default(22) }}"
|
||||
state: started
|
||||
delay: 0
|
||||
timeout: 3
|
||||
delegate_to: localhost
|
||||
register: ssh_check
|
||||
ignore_errors: true
|
||||
- name: Próba połączenia SSH (check online status)
|
||||
block:
|
||||
- name: Sprawdzenie portu SSH
|
||||
ansible.builtin.wait_for:
|
||||
host: "{{ ansible_host | default(inventory_hostname) }}"
|
||||
port: "{{ ansible_port | default(22) }}"
|
||||
state: started
|
||||
delay: 0
|
||||
timeout: 3
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Oznaczenie statusu hosta
|
||||
ansible.builtin.set_fact:
|
||||
host_is_online: "{{ not (ssh_check.failed | default(false)) }}"
|
||||
- name: Ustawienie statusu ONLINE
|
||||
ansible.builtin.set_fact:
|
||||
host_is_online: true
|
||||
rescue:
|
||||
- name: Ustawienie statusu OFFLINE (bez generowania błędu)
|
||||
ansible.builtin.set_fact:
|
||||
host_is_online: false
|
||||
|
||||
# ==========================================
|
||||
# ZBIERANIE FAKTÓW (tylko dla online)
|
||||
# ZBIERANIE FAKTÓW (tylko dla aktywnych hostów)
|
||||
# ==========================================
|
||||
- name: Zbieranie faktów systemowych
|
||||
ansible.builtin.setup:
|
||||
@@ -71,6 +74,7 @@
|
||||
- name: Czyszczenie nieużywanych zasobów Dockera
|
||||
when:
|
||||
- host_is_online
|
||||
- docker_check.rc is defined
|
||||
- docker_check.rc == 0
|
||||
block:
|
||||
- name: Docker system prune (obrazy, sieci, kontenery, wolumeny)
|
||||
|
||||
Reference in New Issue
Block a user