Use loop labels to suppress output

Inside loops ansible does print out each item that it iterates over.
Since we iterate over slurped certificates,
we don't really want to log them or be printed in stdout. So to
reduce output while keeping option for debug, we leverage loop_control
labels, that allow to set what exact data will be printed to stdout.

Change-Id: I36f650f986f17208cf8883d21fbc020cd29f9cd8
This commit is contained in:
Dmitriy Rabotyagov 2023-01-12 16:07:56 +01:00
parent 7b261e2119
commit 241477f59e
2 changed files with 12 additions and 1 deletions

View File

@ -56,6 +56,10 @@
loop: "{{ _cert_slurp.results }}"
loop_control:
loop_var: install
label:
path: "{{ install.item.dest | dirname }}"
state: directory
mode: '0755'
- name: Install Server certificates to targets
copy:
@ -67,7 +71,11 @@
loop: "{{ _cert_slurp.results }}"
loop_control:
loop_var: install
no_log: true
label:
dest: "{{ install.item.dest }}"
owner: "{{ install.item.owner | default(omit) }}"
group: "{{ install.item.group | default('omit') }}"
mode: "{{ install.item.mode | default('0644') }}"
ignore_errors: "{{ ansible_check_mode }}"
notify:
- cert installed

View File

@ -28,6 +28,9 @@
dest: "{{ pki_trust_store_location[ansible_facts['pkg_mgr']] }}/{{ item.item.filename | default(item.item.name ~ '.crt') }}"
register: ca_copy
loop: "{{ _ca_slurp.results | default([]) }}"
loop_control:
label:
dest: "{{ pki_trust_store_location[ansible_facts['pkg_mgr']] }}/{{ item.item.filename | default(item.item.name ~ '.crt') }}"
when: item.skipped is not defined
ignore_errors: "{{ ansible_check_mode }}"