# replacing ini content

**URL:** <https://forum.ansible.com/t/replacing-ini-content/19334>\
**Category:** Ansible Project\
**Created:** [September 23, 2015, 7:02am UTC](https://forum.ansible.com/t/replacing-ini-content/19334 "2015-09-23T07:02:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Edwards](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Chris\_Edwards](https://forum.ansible.com/u/Chris_Edwards)\
**Post date:** [September 23, 2015, 7:02am UTC](https://forum.ansible.com/t/replacing-ini-content/19334/1 "2015-09-23T07:02:42Z")

</div>

I need to save a section from an ini file , copy a new version of the ini file and then replace the values.

for example

**[config]**  
**option1=value1**  
**option2=value2**  
**option3=value3**

**[locations]**  
**location1=uk**  
**location2=us**

save the config section, copy new ini file resulting in

**[config]**  
**option4=value4**  
**option5=value5**  
**option6=value6**

**[locations]**  
**location1=france**  
**location2=china**

then replacing the config section with the original, ending up with

**[config]**  
**option1=value1**  
**option2=value2**  
**option3=value3**

**[locations]**  
**location1=france**  
**location2=china**
