I have managed in the same playbook to generate certain facts and also to 
go over to my local pc and create the file that will receive them.
What hasn't worked is the transfer of said facts. Below you can see what 
I'm generating in the 1st play, I'm using delegate_to & delegate_facts to 
send the data and in the 2nd play, the last task has to gather those facts 
to add them to the file.

Am I using "delegate" correctly or do I have to gather the delegated facts 
differently? Any help would be greatly appreciated

---
- hosts: prueba
tasks:
- name: Tranferir facts a local
setup:
delegate_to: 10.240.5.82
delegate_facts: true
- name: Pagefile Windows
win_pagefile:
register: win_pf
- set_fact: 
swap_gb: '{{ swap_gb | default([]) + [(item.maximum_size - 
item.initial_size) / 1024] }}'
with_items: "{{ win_pf.pagefiles }}"
delegate_to: 10.240.5.82
delegate_facts: true
- hosts: 10.240.5.82
connection: local
tasks:
- name: Ejecucion local
file:
path: '/home/gabriel/Conex_ansible/reporte.csv'
state: touch
run_once: true
- name: Escribir cabecera en archivo csv
shell: echo 'Host, IP Addr, CPUs, Memoria, OS, Arquitectura, Swap, Disco' > 
/home/gabriel/Conex_ansible/reporte.csv
run_once: true
- name: Escribir reporte
shell: echo "{{ ansible_hostname }}, {{ ansible_ip_addresses[0] }}, {{ 
ansible_processor_vcpus }}, {{ ansible_memtotal_mb }}, {{ ansible_os_name 
}}, {{ ansible_architecture }}, {{ swap_gb }}" >> 
/home/gabriel/Conex_ansible/reporte.csv


Inventory is set to:
10.240.5.82

[prueba]
10.240.30.249:5986 ansible_user=admin ansible_password=password 
ansible_connection=winrm ansible_winrm_server_cert_validation=ignore

Current error points the following:

TASK [Ejecucion local] 
*******************************************************************************************
changed: [10.240.5.82]

TASK [Escribir cabecera en archivo csv] 
**************************************************************************
changed: [10.240.5.82]

TASK [Escribir reporte] 
******************************************************************************************
fatal: [10.240.5.82]: FAILED! => {"msg": "The task includes an option with 
an undefined variable. The error was: 'ansible_ip_addresses' is undefined
\n\nThe error appears to be in 
'/home/gabriel/Conex_ansible/main_reporte.yml': line 44, column 9, but may\nbe 
elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n # fs solo muestra los facts locales.\n - 
name: Escribir reporte\n ^ here\n"}

PLAY RECAP 
*******************************************************************************************************
10.240.30.249 : ok=6 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 
ignored=0 
10.240.5.82 : ok=3 changed=2 unreachable=0 failed=1 skipped=0 rescued=0 
ignored=0 



-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f53b7dd8-c298-4a5a-8407-e6c7f9ab3f9a%40googlegroups.com.

Reply via email to