# BlockinFile module help

**URL:** <https://forum.ansible.com/t/blockinfile-module-help/34722>\
**Category:** Ansible Project\
**Created:** [March 4, 2021, 10:11am UTC](https://forum.ansible.com/t/blockinfile-module-help/34722 "2021-03-04T10:11:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akshay\_Kumar](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@Akshay\_Kumar](https://forum.ansible.com/u/Akshay_Kumar)\
**Post date:** [March 4, 2021, 10:11am UTC](https://forum.ansible.com/t/blockinfile-module-help/34722/1 "2021-03-04T10:11:13Z")

</div>

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.
