From 485ba68ebb9f69eba50392472cfddba3e4672ab2 Mon Sep 17 00:00:00 2001 From: djpbessems Date: Tue, 19 Apr 2022 15:49:12 +0200 Subject: [PATCH] Add intermediate task to reduce output spam --- playbook.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/playbook.yml b/playbook.yml index 45e2822..b58690e 100644 --- a/playbook.yml +++ b/playbook.yml @@ -51,9 +51,15 @@ delay: 100 until: job_poll.finished + - name: Parse results into dictionary + ansible.builtin.set_fact: + nodes: "{{ nodes | default([]) + [ {'name': item.instance.hw_name, 'ip': item.item.item.ip | ansible.utils.ipaddr('address')} ] }}" + with_items: "{{ job_poll | json_query('results[*]') }}" + no_log: true + - name: Register new VM's in inventory ansible.builtin.add_host: - name: "{{ item.instance.hw_name }}" - ansible_host: "{{ item.item.item.ip | ansible.utils.ipaddr('address') }}" - groups: k3s-ha - with_items: "{{ job_poll | json_query('results[*]') }}" + name: "{{ item.name }}" + ansible_host: "{{ item.ip }}" + groups: k3s_ha + with_items: "{{ nodes }}"