Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Looping in Ansible usually produces a neat output of one line per iteration (per host): ... ok: [Arch] => (item=something) ok: [Arch] => (item=something_else) ok: [Arch] => (item=yet_a...
Question
ansible
#2: Post edited
- Looping in Ansible usually produces a neat output of one line per iteration (per host):
- ```ansible
- ...
- ok: [Arch] => (item=something)
- ok: [Arch] => (item=something_else)
- ok: [Arch] => (item=yet_another_thing)
- ok: [Arch] => (item=this_better_be_the_last_one)
- ok: [Arch] => (item=ohh_no_it_wasnt)
- ok: [Arch] => (item=they_never_stop_dont_they)
- ...
- ```
However when looping the [assert module](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/assert_module.html) the output is massive:- ```ansible
- ...
- ok: [Arch] => (item=something) => {
- "ansible_loop_var": "item",
- "changed": false,
- "item": "This isn't even an email address.",
- "msg": "All assertions passed"
- }
- ok: [Arch] => (item=something_else) => {
- "ansible_loop_var": "item",
- "changed": false,
- "item": "https://archlinux.org",
- "msg": "All assertions passed"
- }
- ...
- ```
- How to make it neater?
- Looping in Ansible usually produces a neat output of one line per iteration (per host):
- ```ansible
- ...
- ok: [Arch] => (item=something)
- ok: [Arch] => (item=something_else)
- ok: [Arch] => (item=yet_another_thing)
- ok: [Arch] => (item=this_better_be_the_last_one)
- ok: [Arch] => (item=ohh_no_it_wasnt)
- ok: [Arch] => (item=they_never_stop_dont_they)
- ...
- ```
- However when looping with the [assert module](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/assert_module.html) the output is massive:
- ```ansible
- ...
- ok: [Arch] => (item=something) => {
- "ansible_loop_var": "item",
- "changed": false,
- "item": "This isn't even an email address.",
- "msg": "All assertions passed"
- }
- ok: [Arch] => (item=something_else) => {
- "ansible_loop_var": "item",
- "changed": false,
- "item": "https://archlinux.org",
- "msg": "All assertions passed"
- }
- ...
- ```
- How to make it neater?
#1: Initial revision
Tidy Ansible assert module loop output
Looping in Ansible usually produces a neat output of one line per iteration (per host): ```ansible ... ok: [Arch] => (item=something) ok: [Arch] => (item=something_else) ok: [Arch] => (item=yet_another_thing) ok: [Arch] => (item=this_better_be_the_last_one) ok: [Arch] => (item=ohh_no_it_wasnt) ok: [Arch] => (item=they_never_stop_dont_they) ... ``` However when looping the [assert module](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/assert_module.html) the output is massive: ```ansible ... ok: [Arch] => (item=something) => { "ansible_loop_var": "item", "changed": false, "item": "This isn't even an email address.", "msg": "All assertions passed" } ok: [Arch] => (item=something_else) => { "ansible_loop_var": "item", "changed": false, "item": "https://archlinux.org", "msg": "All assertions passed" } ... ``` How to make it neater?