Skip to content

Commit a585264

Browse files
committed
fix(playbooks/tests/hammer-list.yaml): Properly deal with a list of results
rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED
1 parent 71dcbb2 commit a585264

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

playbooks/tests/hammer-list.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
---
22
- hosts: satellite6
3-
gather_facts: False
3+
gather_facts: false
44
tasks:
55
- name: "Run 'hammer host list' command"
66
ansible.builtin.shell:
77
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" host list --organization "{{ organization }}" --page 1 --per-page 100 >/dev/null
8-
register: run_hammer
9-
loop: "{{ range(30)|list }}"
108
environment:
119
TZ: UTC
10+
register: run_hammer
11+
loop: "{{ range(30) | list }}"
1212

1313
- name: "Calculate command duration"
1414
ansible.builtin.set_fact:
15-
run_hammer_duration: "{{ (run_hammer.end | to_datetime('%Y-%m-%d %H:%M:%S.%f')).timestamp() - (run_hammer.start | to_datetime('%Y-%m-%d %H:%M:%S.%f')).timestamp() }}"
15+
combined: "{{ combined + [item | combine( { 'duration': (item.end | to_datetime('%Y-%m-%d %H:%M:%S.%f')).timestamp() - (item.start | to_datetime('%Y-%m-%d %H:%M:%S.%f')).timestamp() } )] }}"
16+
vars:
17+
combined: []
18+
loop: "{{ run_hammer.results }}"
1619

1720
- name: "Print results"
1821
ansible.builtin.debug:
19-
msg: "HammerHostList {{ item.start }} to {{ item.end }} taking {{ run_hammer_duration }} seconds"
20-
loop: "{{ run_hammer.results }}"
22+
msg: "HammerHostList {{ item.start }} to {{ item.end }} taking {{ item.duration }} seconds"
23+
loop: "{{ combined }}"
24+
...

0 commit comments

Comments
 (0)