# Editing a YAML file, using Ansible

**URL:** <https://forum.ansible.com/t/editing-a-yaml-file-using-ansible/26993>\
**Category:** Ansible Project\
**Created:** [March 14, 2018, 10:31am UTC](https://forum.ansible.com/t/editing-a-yaml-file-using-ansible/26993 "2018-03-14T10:31:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ykaul](https://avatars.discourse-cdn.com/v4/letter/y/4af34b/32.png) [@ykaul](https://forum.ansible.com/u/ykaul)\
**Post date:** [March 14, 2018, 10:31am UTC](https://forum.ansible.com/t/editing-a-yaml-file-using-ansible/26993/1 "2018-03-14T10:31:25Z")

</div>

I’m trying to edit a YAML file (Ansible playbook, who knew) using the replace module.  
What I’d like to do is something like:  
original:

cloud\_init:

to:

cloud\_init:  
custom\_script: “{{ install\_guest\_agent\_script }}”

Which means that I somehow need to escape the " chars and the {{ and }} - and I have no idea how to make this happen.

To make things slightly more complex, I’m actually pushing also the var install\_guest\_agent\_script into that YAML…  
So my code looks something like this:
