From 99a9fbc8ae6ad91603e08e70c78e11ca9dc15573 Mon Sep 17 00:00:00 2001 From: Olli Graf Date: Sat, 26 Jul 2025 08:52:35 +0200 Subject: [PATCH] retries und with_dict --- retries.yml | 6 ++++++ roles/retries/tasks/main.yml | 8 ++++++++ roles/with_dict/tasks/main.yml | 11 +++++++++++ roles/with_lines/tasks/main.yml | 2 +- with_dict.yml | 6 ++++++ 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 retries.yml create mode 100644 roles/retries/tasks/main.yml create mode 100644 roles/with_dict/tasks/main.yml create mode 100644 with_dict.yml diff --git a/retries.yml b/retries.yml new file mode 100644 index 0000000..31ea4d0 --- /dev/null +++ b/retries.yml @@ -0,0 +1,6 @@ +- hosts: "{{ target }}" + gather_facts: false + remote_user: pi + roles: + - retries + diff --git a/roles/retries/tasks/main.yml b/roles/retries/tasks/main.yml new file mode 100644 index 0000000..99dbc32 --- /dev/null +++ b/roles/retries/tasks/main.yml @@ -0,0 +1,8 @@ +- name: Warte bis Container läuft + docker_container_info: + name: homeassistant + register: container_info + until: container_info.container.State.Status == "running" + retries: 20 + delay: 3 + # Wartet bis Container vollständig gestartet ist diff --git a/roles/with_dict/tasks/main.yml b/roles/with_dict/tasks/main.yml new file mode 100644 index 0000000..8c4332f --- /dev/null +++ b/roles/with_dict/tasks/main.yml @@ -0,0 +1,11 @@ +- name: Benutzer mit bestimmten Shells anlegen + vars: + users: + alice: /bin/bash + bob: /bin/zsh + carol: /bin/sh + + debug: + msg: "Lege neuen User an Name: {{ item.key }} Shell: {{ item.value }}" + with_dict: "{{ users }}" + diff --git a/roles/with_lines/tasks/main.yml b/roles/with_lines/tasks/main.yml index 7dfa5d6..7ef9e4d 100644 --- a/roles/with_lines/tasks/main.yml +++ b/roles/with_lines/tasks/main.yml @@ -1,4 +1,4 @@ -- name: "Beispiel 1: Alle .conf Dateien in /etc auflisten" +- name: "Beispiel: Alle .conf Dateien in /etc auflisten" debug: msg: "Gefundene Konfigurationsdatei: {{ item }}" with_lines: diff --git a/with_dict.yml b/with_dict.yml new file mode 100644 index 0000000..4ee8ff2 --- /dev/null +++ b/with_dict.yml @@ -0,0 +1,6 @@ +- hosts: "{{ target }}" + gather_facts: false + remote_user: pi + roles: + - with_dict +