Hi, All.

It's been some time since I used Ansible, and this list. I'm happy to be 
back using both.

I've created a [playbook to run pin, and create a report of output:

---
- name: check reachable hosts
hosts: dytest
gather_facts: no
tasks:
- name: Ping each host
ansible.builtin.command: ping -c1 {{ item }}
run_once: true
loop: "{{ ansible_play_hosts_all }}"
delegate_to: localhost
register: ping_result
failed_when: false

- name: How did we do?
ansible.builtin.debug:
msg: "{{ ping_result.results[0] }}"
run_once: true

- name: Format it a bit
# Note: the docs for 'copy' say don't do this, to use template instead,
# and there are reasons, but this suffices for posting purposes.
# The 'content:' below should be in your template.
ansible.builtin.copy:
dest: /home/deploy/ping.txt
content: |
--- PING REPORT ---
{% for pr in ping_result.results %}
{{ pr.stdout_lines | first }}
{{ pr.stdout_lines | last }}

{% endfor %}
run_once: true
delegate_to: localhost

That works fine. However, I want to use ansible.builtin.ping, not regular 
ping. When I substitute in ansible.builtin ping, I get the error:

fatal: [bed-test-9-dy1]: FAILED! => {"msg": "The task includes an option 
with an undefined variable. The error was: 'dict object' has no attribute 
'stdout'. 'dict object' has no attribute 'stdout'\n\nThe error appears to 
be in '/etc/ansible/playbooks/ping4.yml': line 15, column 7, but may\nbe 
elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n    - name: How did we do?\n 

What do I need to do to accomplish what I'm after?

Many thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e7a88e24-658d-40f1-b6ab-d7a152c79109n%40googlegroups.com.

Reply via email to