Hi Guys ,

I am using the below block for writing a variable values into a file

  - name: Add output of task for getting content to the local
    local_action:
      module: blockinfile
      path: "{{ File }}"
      marker: " "
      state: present
      block: |
           {{ item }}:
           {{ hostvars[item]['CronOutput'].stdout | default(['No Cron 
Entries'])  }}
      insertafter: EOF
    run_once: true
    with_items:
      - "{{ play_hosts }}"

In this for a host when there is not value in "CronOutput" variable , i 
want Default string to be printed into file for that host but it is not 
working , anyonw have an idea about the same?

I tried this also :
{{ hostvars[item]['CronOutput'].stdout | default('No Cron Entries')  }}
{{ hostvars[item]['CronOutput'].stdout | default("No Cron Entries")  }}

Thanks in advance.

-- 
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/1325ba8e-ad46-4c01-8cdb-3fbe8a5c2016n%40googlegroups.com.

Reply via email to